Skip to content

Commit

Permalink
Fix deprecated method
Browse files Browse the repository at this point in the history
  • Loading branch information
oherrala committed Feb 11, 2024
1 parent 9fa0534 commit c1b9e50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion energiatili-model/src/measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ where
}

fn convert_timestamp(timestamp: i64) -> DateTime<Utc> {
let naive_date = NaiveDateTime::from_timestamp((timestamp / 1000) as i64, 0);
let naive_date = NaiveDateTime::from_timestamp_opt((timestamp / 1000) as i64, 0).expect("parse NaiveDateTime");
let localtime = match Helsinki.from_local_datetime(&naive_date) {
LocalResult::None => panic!("Couldn't convert local time"),
LocalResult::Single(t) => t,
Expand Down
2 changes: 1 addition & 1 deletion energiatili-model/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn fix_new_date(buf: &str) -> String {

// Javascript's "new Date()" supposed to be seconds since UNIX epoch UTC,
// but it seems Energiatili's numbers are in finnish timezone instead.
let naive_date = NaiveDateTime::from_timestamp(date_int / 1000, 0);
let naive_date = NaiveDateTime::from_timestamp_opt(date_int / 1000, 0).expect("parse NaiveDateTime");
let localtime = Helsinki.from_local_datetime(&naive_date).unwrap();
let timestamp: DateTime<Utc> = localtime.with_timezone(&Utc);

Expand Down

0 comments on commit c1b9e50

Please sign in to comment.