Fix #378 — formatting of dates/times
This commit is contained in:
parent
0708fdfb37
commit
f1b3749cf0
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -554,7 +554,7 @@ checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libreddit"
|
name = "libreddit"
|
||||||
version = "0.21.3"
|
version = "0.21.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
|
@ -3,7 +3,7 @@ name = "libreddit"
|
|||||||
description = " Alternative private front-end to Reddit"
|
description = " Alternative private front-end to Reddit"
|
||||||
license = "AGPL-3.0"
|
license = "AGPL-3.0"
|
||||||
repository = "https://github.com/spikecodes/libreddit"
|
repository = "https://github.com/spikecodes/libreddit"
|
||||||
version = "0.21.3"
|
version = "0.21.4"
|
||||||
authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"]
|
authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ async fn user(name: &str) -> Result<User, String> {
|
|||||||
title: esc!(about("title")),
|
title: esc!(about("title")),
|
||||||
icon: format_url(&about("icon_img")),
|
icon: format_url(&about("icon_img")),
|
||||||
karma: res["data"]["total_karma"].as_i64().unwrap_or(0),
|
karma: res["data"]["total_karma"].as_i64().unwrap_or(0),
|
||||||
created: created.format(format_description!("%b %d '%y")).unwrap_or_default(),
|
created: created.format(format_description!("[month repr:short] [day] '[year repr:last_two]")).unwrap_or_default(),
|
||||||
banner: esc!(about("banner_img")),
|
banner: esc!(about("banner_img")),
|
||||||
description: about("public_description"),
|
description: about("public_description"),
|
||||||
}
|
}
|
||||||
|
@ -642,7 +642,7 @@ pub fn time(created: f64) -> (String, String) {
|
|||||||
|
|
||||||
// If the time difference is more than a month, show full date
|
// If the time difference is more than a month, show full date
|
||||||
let rel_time = if time_delta > Duration::days(30) {
|
let rel_time = if time_delta > Duration::days(30) {
|
||||||
time.format(format_description!("%b %d '%y")).unwrap_or_default()
|
time.format(format_description!("[month repr:short] [day] '[year repr:last_two]")).unwrap_or_default()
|
||||||
// Otherwise, show relative date/time
|
// Otherwise, show relative date/time
|
||||||
} else if time_delta.whole_days() > 0 {
|
} else if time_delta.whole_days() > 0 {
|
||||||
format!("{}d ago", time_delta.whole_days())
|
format!("{}d ago", time_delta.whole_days())
|
||||||
@ -652,7 +652,7 @@ pub fn time(created: f64) -> (String, String) {
|
|||||||
format!("{}m ago", time_delta.whole_minutes())
|
format!("{}m ago", time_delta.whole_minutes())
|
||||||
};
|
};
|
||||||
|
|
||||||
(rel_time, time.format(format_description!("%b %d %Y, %H:%M:%S UTC")).unwrap_or_default())
|
(rel_time, time.format(format_description!("[month repr:short] [day] [year], [hour]:[minute]:[second] UTC")).unwrap_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
// val() function used to parse JSON from Reddit APIs
|
// val() function used to parse JSON from Reddit APIs
|
||||||
|
Loading…
Reference in New Issue
Block a user