Merge pull request #30 from dvdsk/master
Fixes #29 and displays pasta list in local timezone
This commit is contained in:
commit
a5d326b679
1 changed files with 5 additions and 6 deletions
11
src/pasta.rs
11
src/pasta.rs
|
@ -1,6 +1,6 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use chrono::{DateTime, Datelike, NaiveDateTime, Timelike, Utc};
|
use chrono::{Datelike, Timelike, Local, TimeZone};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::util::animalnumbers::to_animal_names;
|
use crate::util::animalnumbers::to_animal_names;
|
||||||
|
@ -25,9 +25,9 @@ impl Pasta {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn created_as_string(&self) -> String {
|
pub fn created_as_string(&self) -> String {
|
||||||
let date = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(self.created, 0), Utc);
|
let date = Local.timestamp(self.created, 0);
|
||||||
format!(
|
format!(
|
||||||
"{:02}-{:02} {}:{}",
|
"{:02}-{:02} {:02}:{:02}",
|
||||||
date.month(),
|
date.month(),
|
||||||
date.day(),
|
date.day(),
|
||||||
date.hour(),
|
date.hour(),
|
||||||
|
@ -39,10 +39,9 @@ impl Pasta {
|
||||||
if self.expiration == 0 {
|
if self.expiration == 0 {
|
||||||
String::from("Never")
|
String::from("Never")
|
||||||
} else {
|
} else {
|
||||||
let date =
|
let date = Local.timestamp(self.expiration, 0);
|
||||||
DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(self.expiration, 0), Utc);
|
|
||||||
format!(
|
format!(
|
||||||
"{:02}-{:02} {}:{}",
|
"{:02}-{:02} {:02}:{:02}",
|
||||||
date.month(),
|
date.month(),
|
||||||
date.day(),
|
date.day(),
|
||||||
date.hour(),
|
date.hour(),
|
||||||
|
|
Loading…
Reference in a new issue