Add days to time()

This commit is contained in:
spikecodes 2021-01-13 16:31:24 -08:00
parent 740641cb4e
commit f95ef51017

View File

@ -226,8 +226,10 @@ pub fn parse_rich_flair(flair_type: String, rich_flair: Option<&Vec<Value>>, tex
pub fn time(unix_time: i64) -> String { pub fn time(unix_time: i64) -> String {
let time = OffsetDateTime::from_unix_timestamp(unix_time); let time = OffsetDateTime::from_unix_timestamp(unix_time);
let time_delta = OffsetDateTime::now_utc() - time; let time_delta = OffsetDateTime::now_utc() - time;
if time_delta > Duration::days(1) { if time_delta > Duration::days(30) {
time.format("%b %d '%y") // %b %e '%y time.format("%b %d '%y") // %b %e '%y
} else if time_delta.whole_days() > 0 {
format!("{}d ago", time_delta.whole_days())
} else if time_delta.whole_hours() > 0 { } else if time_delta.whole_hours() > 0 {
format!("{}h ago", time_delta.whole_hours()) format!("{}h ago", time_delta.whole_hours())
} else { } else {