Skip to content

Commit 4cffe1d

Browse files
feat(web): enhance time formatting logic in posts for clearer user indications of post age
1 parent d881642 commit 4cffe1d

File tree

1 file changed

+5
-3
lines changed
  • crates/web/src/components/feed

1 file changed

+5
-3
lines changed

crates/web/src/components/feed/post.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@ pub fn Post(post: PostsPostsEdgesNode) -> impl IntoView {
1515
.num_seconds();
1616

1717
let format_string = match diff_in_seconds {
18+
// More than 3 days
1819
_ if diff_in_seconds > 86400 * LONG_TO_SHORT_CUTOFF_DAYS => "%m/%d/%y".to_string(), // More than 3 days
1920
diff_in_seconds if diff_in_seconds > 86400 => {
2021
format!("{} Days ago", diff_in_seconds / 86400)
21-
} // Within 3 days
22+
}
23+
// Within 3 days
2224
diff_in_seconds if diff_in_seconds > 3600 => {
2325
format!("{} hours ago", diff_in_seconds / 3600)
24-
} // Within 1 day
26+
} // Within 1 hour
2527
diff_in_seconds if diff_in_seconds > 60 => {
2628
format!("{} minutes ago", diff_in_seconds / 60)
27-
} // Within 1 hour
29+
} // Within 1 minute
2830
_ => format!("{} seconds ago", diff_in_seconds),
2931
};
3032

0 commit comments

Comments
 (0)