version-helper: Update for deprecated chrono functions

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/978>
This commit is contained in:
Sebastian Dröge 2022-11-12 18:24:02 +02:00
parent 37cb636140
commit 3094bd96df
2 changed files with 5 additions and 3 deletions

View file

@ -13,4 +13,4 @@ edition = "2021"
rust-version = "1.63"
[dependencies]
chrono = { version = "0.4.19", default-features = false, features = ["std", "clock"] }
chrono = { version = "0.4.23", default-features = false, features = ["std", "clock"] }

View file

@ -85,10 +85,12 @@ fn cargo_mtime_date(crate_dir: path::PathBuf) -> Option<chrono::DateTime<chrono:
let metadata = fs::metadata(&cargo_toml).ok()?;
let mtime = metadata.modified().ok()?;
let unix_time = mtime.duration_since(SystemTime::UNIX_EPOCH).ok()?;
let dt = chrono::Utc.timestamp(unix_time.as_secs().try_into().ok()?, 0);
let dt = chrono::Utc
.timestamp_opt(unix_time.as_secs().try_into().ok()?, 0)
.latest()?;
// FIXME: Work around https://github.com/rust-lang/cargo/issues/10285
if dt.date().year() < 2015 {
if dt.date_naive().year() < 2015 {
return None;
}