Compare commits
2 Commits
f6c1835b18
...
6901c9fde9
| Author | SHA1 | Date | |
|---|---|---|---|
| 6901c9fde9 | |||
| 6251c54873 |
@ -47,7 +47,7 @@ iframe {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.index .date {
|
.index .date {
|
||||||
width: 6em;
|
width: 7em;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -484,21 +484,24 @@ fn pretty_authors(authors: &str) -> impl Iterator<Item = Node<Msg>> + '_ {
|
|||||||
|
|
||||||
fn human_age(timestamp: i64) -> String {
|
fn human_age(timestamp: i64) -> String {
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
|
let yesterday = now - Duration::days(1);
|
||||||
let ts = DateTime::<Utc>::from_timestamp(timestamp, 0)
|
let ts = DateTime::<Utc>::from_timestamp(timestamp, 0)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&Local);
|
.with_timezone(&Local);
|
||||||
let age = now - ts;
|
let age = now - ts;
|
||||||
let weekday = now.weekday();
|
let weekday = now.weekday();
|
||||||
let datetime = if age < Duration::minutes(1) {
|
let datetime = if age < Duration::minutes(1) {
|
||||||
format!("{} ago", age.num_seconds())
|
format!("{} min. ago", age.num_seconds())
|
||||||
} else if age < Duration::hours(1) {
|
} else if age < Duration::hours(1) {
|
||||||
format!("{} ago", age.num_minutes())
|
format!("{} min. ago", age.num_minutes())
|
||||||
} else if age < Duration::days(1) {
|
} else if ts.date_naive() == now.date_naive() {
|
||||||
ts.format("%H:%M").to_string()
|
ts.format("Today %H:%M").to_string()
|
||||||
|
} else if ts.date_naive() == yesterday.date_naive() {
|
||||||
|
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 {
|
} else {
|
||||||
ts.format("%b %e").to_string()
|
ts.format("%b %e %H:%M").to_string()
|
||||||
};
|
};
|
||||||
info!("dateime {datetime} TZ: {}", ts.offset());
|
info!("dateime {datetime} TZ: {}", ts.offset());
|
||||||
datetime
|
datetime
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user