Skip to content

Commit 674090d

Browse files
cafkafkerwinvaneijk
andcommitted
fix: remove depricated chrono from_timestamp_opt
Co-authored-by: Erwin van Eijk <[email protected]> Signed-off-by: Christina Sørensen <[email protected]>
1 parent 4d43683 commit 674090d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: src/fs/file.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,11 @@ impl<'dir> File<'dir> {
755755
fn systemtime_to_naivedatetime(st: SystemTime) -> Option<NaiveDateTime> {
756756
let duration = st.duration_since(SystemTime::UNIX_EPOCH).ok()?;
757757

758-
// FIXME: NaiveDateTime::from_timestamp_opt is deprecated since chrono 0.4.35
759-
NaiveDateTime::from_timestamp_opt(
758+
DateTime::from_timestamp(
760759
duration.as_secs().try_into().ok()?,
761760
(duration.as_nanos() % 1_000_000_000).try_into().ok()?,
762761
)
762+
.map(|dt| dt.naive_local())
763763
}
764764

765765
/// This file’s last modified timestamp, if available on this platform.
@@ -786,10 +786,11 @@ impl<'dir> File<'dir> {
786786
};
787787
}
788788
let md = self.metadata();
789-
NaiveDateTime::from_timestamp_opt(
789+
DateTime::from_timestamp(
790790
md.map_or(0, MetadataExt::ctime),
791791
md.map_or(0, |md| md.ctime_nsec() as u32),
792792
)
793+
.map(|dt| dt.naive_local())
793794
}
794795

795796
#[cfg(windows)]

0 commit comments

Comments
 (0)