Skip to content

Commit

Permalink
fix: [torrust#132] deprecate chrono function warning
Browse files Browse the repository at this point in the history
```
warning: use of deprecated associated function `chrono::NaiveDateTime::from_timestamp`: use `from_timestamp_opt()` instead
  --> src/upgrades/from_v1_0_0_to_v2_0_0/databases/sqlite_v2_0_0.rs:53:41
   |
53 |     let naive_datetime = NaiveDateTime::from_timestamp(timestamp, 0);
   |                                         ^^^^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default
```
  • Loading branch information
josecelano committed May 5, 2023
1 parent 7dbcafd commit d2f8db9
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ impl TorrentRecordV2 {
}
}

#[must_use]
pub fn convert_timestamp_to_datetime(timestamp: i64) -> String {
// The expected format in database is: 2022-11-04 09:53:57
// MySQL uses a DATETIME column and SQLite uses a TEXT column.

let naive_datetime = NaiveDateTime::from_timestamp(timestamp, 0);
let naive_datetime = NaiveDateTime::from_timestamp_opt(timestamp, 0).expect("Overflow of i64 seconds, very future!");
let datetime_again: DateTime<Utc> = DateTime::from_utc(naive_datetime, Utc);

// Format without timezone
Expand Down

0 comments on commit d2f8db9

Please sign in to comment.