Add special delta format case for 0
This commit is contained in:
parent
df4e44d338
commit
84994ac347
1 changed files with 3 additions and 0 deletions
|
|
@ -25,6 +25,9 @@ pub fn time_to_offset_datetime(time: Time) -> somehow::Result<OffsetDateTime> {
|
||||||
pub fn format_delta(delta: time::Duration) -> String {
|
pub fn format_delta(delta: time::Duration) -> String {
|
||||||
let seconds = delta.unsigned_abs().as_secs();
|
let seconds = delta.unsigned_abs().as_secs();
|
||||||
let seconds = seconds + 30 - (seconds + 30) % 60; // To nearest minute
|
let seconds = seconds + 30 - (seconds + 30) % 60; // To nearest minute
|
||||||
|
if seconds == 0 {
|
||||||
|
return "now".to_string();
|
||||||
|
}
|
||||||
let formatted = humantime::format_duration(Duration::from_secs(seconds));
|
let formatted = humantime::format_duration(Duration::from_secs(seconds));
|
||||||
if delta.is_positive() {
|
if delta.is_positive() {
|
||||||
format!("in {formatted}")
|
format!("in {formatted}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue