fix: update references to old from_time API

This commit is contained in:
Marli Frost 2023-02-01 14:01:53 +00:00
parent ccd20c118e
commit 42eabc9e33
2 changed files with 7 additions and 6 deletions

View file

@ -511,20 +511,22 @@ mod test {
#[cfg(feature = "time")]
#[test]
fn datetime_from_time_bounds() {
use std::convert::TryFrom;
use super::DateTime;
use time::macros::datetime;
// 1979-12-31 23:59:59
assert!(DateTime::from_time(datetime!(1979-12-31 23:59:59 UTC)).is_err());
assert!(DateTime::try_from(datetime!(1979-12-31 23:59:59 UTC)).is_err());
// 1980-01-01 00:00:00
assert!(DateTime::from_time(datetime!(1980-01-01 00:00:00 UTC)).is_ok());
assert!(DateTime::try_from(datetime!(1980-01-01 00:00:00 UTC)).is_ok());
// 2107-12-31 23:59:59
assert!(DateTime::from_time(datetime!(2107-12-31 23:59:59 UTC)).is_ok());
assert!(DateTime::try_from(datetime!(2107-12-31 23:59:59 UTC)).is_ok());
// 2108-01-01 00:00:00
assert!(DateTime::from_time(datetime!(2108-01-01 00:00:00 UTC)).is_err());
assert!(DateTime::try_from(datetime!(2108-01-01 00:00:00 UTC)).is_err());
}
#[cfg(feature = "time")]
@ -601,7 +603,6 @@ mod test {
// 2020-01-01 00:00:00
let clock = OffsetDateTime::from_unix_timestamp(1_577_836_800).unwrap();
assert!(DateTime::from_time(clock).is_ok());
assert!(DateTime::try_from(clock).is_ok());
}
}

View file

@ -191,7 +191,7 @@ impl Default for FileOptions {
compression_method: CompressionMethod::Stored,
compression_level: None,
#[cfg(feature = "time")]
last_modified_time: DateTime::from_time(OffsetDateTime::now_utc()).unwrap_or_default(),
last_modified_time: OffsetDateTime::now_utc().try_into().unwrap_or_default(),
#[cfg(not(feature = "time"))]
last_modified_time: DateTime::default(),
permissions: None,