From de2cc48f88f2f7132e21dc7e36ab3c282c195658 Mon Sep 17 00:00:00 2001 From: dvdsk Date: Wed, 13 Jul 2022 23:54:48 +0200 Subject: [PATCH 1/2] fixes #29 (time formating) --- src/pasta.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pasta.rs b/src/pasta.rs index 66cd342..f514522 100644 --- a/src/pasta.rs +++ b/src/pasta.rs @@ -27,7 +27,7 @@ impl Pasta { pub fn created_as_string(&self) -> String { let date = DateTime::::from_utc(NaiveDateTime::from_timestamp(self.created, 0), Utc); format!( - "{:02}-{:02} {}:{}", + "{:02}-{:02} {:02}:{:02}", date.month(), date.day(), date.hour(), @@ -42,7 +42,7 @@ impl Pasta { let date = DateTime::::from_utc(NaiveDateTime::from_timestamp(self.expiration, 0), Utc); format!( - "{:02}-{:02} {}:{}", + "{:02}-{:02} {:02}:{:02}", date.month(), date.day(), date.hour(), From 738e036cb56dac98f9fc50bdd41a5ebed4a72604 Mon Sep 17 00:00:00 2001 From: dvdsk Date: Wed, 13 Jul 2022 23:55:28 +0200 Subject: [PATCH 2/2] pasta times are in systems local timezone --- src/pasta.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pasta.rs b/src/pasta.rs index f514522..ca9e95a 100644 --- a/src/pasta.rs +++ b/src/pasta.rs @@ -1,6 +1,6 @@ use std::fmt; -use chrono::{DateTime, Datelike, NaiveDateTime, Timelike, Utc}; +use chrono::{Datelike, Timelike, Local, TimeZone}; use serde::{Deserialize, Serialize}; use crate::util::animalnumbers::to_animal_names; @@ -25,7 +25,7 @@ impl Pasta { } pub fn created_as_string(&self) -> String { - let date = DateTime::::from_utc(NaiveDateTime::from_timestamp(self.created, 0), Utc); + let date = Local.timestamp(self.created, 0); format!( "{:02}-{:02} {:02}:{:02}", date.month(), @@ -39,8 +39,7 @@ impl Pasta { if self.expiration == 0 { String::from("Never") } else { - let date = - DateTime::::from_utc(NaiveDateTime::from_timestamp(self.expiration, 0), Utc); + let date = Local.timestamp(self.expiration, 0); format!( "{:02}-{:02} {:02}:{:02}", date.month(),