Also changed expiration date to show "Never" instead of unix epoch in the pasta list, and renamed a few variables in animalnumbers.rs to make the function more readable.
This commit is contained in:
Daniel Szabo 2022-05-09 22:36:13 +01:00
parent 9e4940eb44
commit cd2eea30ce
3 changed files with 30 additions and 28 deletions

View file

@ -32,15 +32,19 @@ impl Pasta {
}
pub fn expiration_as_string(&self) -> String {
let date =
DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(self.expiration, 0), Utc);
format!(
"{:02}-{:02} {}:{}",
date.month(),
date.day(),
date.hour(),
date.minute(),
)
if self.expiration == 0 {
String::from("Never")
} else {
let date =
DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(self.expiration, 0), Utc);
format!(
"{:02}-{:02} {}:{}",
date.month(),
date.day(),
date.hour(),
date.minute(),
)
}
}
}