diff --git a/Cargo.lock b/Cargo.lock index b3fd72197..6addab7b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -658,9 +658,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.34" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/src/imex.rs b/src/imex.rs index e1887236c..235c97f5e 100644 --- a/src/imex.rs +++ b/src/imex.rs @@ -499,7 +499,7 @@ fn get_next_backup_path( backup_time: i64, ) -> Result<(PathBuf, PathBuf, PathBuf)> { let folder = PathBuf::from(folder); - let stem = chrono::NaiveDateTime::from_timestamp_opt(backup_time, 0) + let stem = chrono::DateTime::::from_timestamp(backup_time, 0) .context("can't get next backup path")? // Don't change this file name format, in `dc_imex_has_backup` we use string comparison to determine which backup is newer: .format("delta-chat-backup-%Y-%m-%d") diff --git a/src/location.rs b/src/location.rs index 879bd27e4..d5a2337c1 100644 --- a/src/location.rs +++ b/src/location.rs @@ -137,7 +137,7 @@ impl Kml { // 0 4 7 10 13 16 19 match chrono::NaiveDateTime::parse_from_str(&val, "%Y-%m-%dT%H:%M:%SZ") { Ok(res) => { - self.curr.timestamp = res.timestamp(); + self.curr.timestamp = res.and_utc().timestamp(); let now = time(); if self.curr.timestamp > now { self.curr.timestamp = now; @@ -540,7 +540,7 @@ pub async fn get_kml(context: &Context, chat_id: ChatId) -> Result String { // Returns a string formatted as YYYY-MM-DDTHH:MM:SSZ. The trailing `Z` indicates UTC. - chrono::NaiveDateTime::from_timestamp_opt(utc, 0) + chrono::DateTime::::from_timestamp(utc, 0) .unwrap() .format("%Y-%m-%dT%H:%M:%SZ") .to_string() diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 46fe794c3..84a35abfd 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -575,11 +575,7 @@ impl<'a> MimeFactory<'a> { .protected .push(Header::new("Subject".into(), encoded_subject)); - let date = chrono::Utc - .from_local_datetime( - &chrono::NaiveDateTime::from_timestamp_opt(self.timestamp, 0) - .context("can't convert timestamp to NativeDateTime")?, - ) + let date = chrono::DateTime::::from_timestamp(self.timestamp, 0) .unwrap() .to_rfc2822(); headers.unprotected.push(Header::new("Date".into(), date)); diff --git a/src/tools.rs b/src/tools.rs index e26c49dd8..aa434ca10 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -181,6 +181,7 @@ pub fn get_release_timestamp() -> i64 { *crate::release::DATE, NaiveTime::from_hms_opt(0, 0, 0).unwrap(), ) + .and_utc() .timestamp_millis() / 1_000 } @@ -205,7 +206,7 @@ async fn maybe_warn_on_bad_time(context: &Context, now: i64, known_past_timestam ), ) .await; - if let Some(timestamp) = chrono::NaiveDateTime::from_timestamp_opt(now, 0) { + if let Some(timestamp) = chrono::DateTime::::from_timestamp(now, 0) { add_device_msg_with_importance( context, Some( @@ -232,7 +233,7 @@ async fn maybe_warn_on_outdated(context: &Context, now: i64, approx_compile_time if now > approx_compile_time + DC_OUTDATED_WARNING_DAYS * 24 * 60 * 60 { let mut msg = Message::new(Viewtype::Text); msg.text = stock_str::update_reminder_msg_body(context).await; - if let Some(timestamp) = chrono::NaiveDateTime::from_timestamp_opt(now, 0) { + if let Some(timestamp) = chrono::DateTime::::from_timestamp(now, 0) { add_device_msg( context, Some( @@ -1214,6 +1215,7 @@ DKIM Results: Passed=true, Works=true, Allow_Keychange=true"; NaiveDate::from_ymd_opt(2020, 9, 1).unwrap(), NaiveTime::from_hms_opt(0, 0, 0).unwrap(), ) + .and_utc() .timestamp_millis() / 1_000; @@ -1329,6 +1331,7 @@ DKIM Results: Passed=true, Works=true, Allow_Keychange=true"; NaiveDate::from_ymd_opt(2020, 9, 9).unwrap(), NaiveTime::from_hms_opt(0, 0, 0).unwrap(), ) + .and_utc() .timestamp_millis() / 1_000; assert!(get_release_timestamp() <= time());