From f95ef51017582a8ebe5d8c7f04b593e1437f0c5a Mon Sep 17 00:00:00 2001 From: spikecodes <19519553+spikecodes@users.noreply.github.com> Date: Wed, 13 Jan 2021 16:31:24 -0800 Subject: [PATCH] Add days to time() --- src/utils.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index c6120ac..a82cb3d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -226,8 +226,10 @@ pub fn parse_rich_flair(flair_type: String, rich_flair: Option<&Vec>, tex pub fn time(unix_time: i64) -> String { let time = OffsetDateTime::from_unix_timestamp(unix_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 + } else if time_delta.whole_days() > 0 { + format!("{}d ago", time_delta.whole_days()) } else if time_delta.whole_hours() > 0 { format!("{}h ago", time_delta.whole_hours()) } else {