web: better date formatting

This commit is contained in:
Bill Thiede 2023-11-26 16:01:22 -08:00
parent 02e16b4547
commit 1cdabc348b
2 changed files with 5 additions and 3 deletions

View File

@ -47,7 +47,7 @@ iframe {
white-space: nowrap; white-space: nowrap;
} }
.index .date { .index .date {
width: 7em; width: 10em;
white-space: nowrap; white-space: nowrap;
text-align: right; text-align: right;
} }

View File

@ -7,7 +7,7 @@ use std::{
hash::{Hash, Hasher}, hash::{Hash, Hasher},
}; };
use chrono::{DateTime, Duration, Local, Utc}; use chrono::{DateTime, Datelike, Duration, Local, Utc};
use graphql_client::GraphQLQuery; use graphql_client::GraphQLQuery;
use itertools::Itertools; use itertools::Itertools;
use log::{debug, error, info, Level}; use log::{debug, error, info, Level};
@ -708,8 +708,10 @@ fn human_age(timestamp: i64) -> String {
ts.format("Yest. %H:%M").to_string() ts.format("Yest. %H:%M").to_string()
} else if age < Duration::weeks(1) { } else if age < Duration::weeks(1) {
ts.format("%a %H:%M").to_string() ts.format("%a %H:%M").to_string()
} else if ts.year() == now.year() {
ts.format("%b %d %H:%M").to_string()
} else { } else {
ts.format("%b %e %H:%M").to_string() ts.format("%b %d, %Y %H:%M").to_string()
}; };
datetime datetime
} }