mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-06 14:50:18 +00:00
Add days to time()
This commit is contained in:
parent
740641cb4e
commit
f95ef51017
1 changed files with 3 additions and 1 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue