Skip to content

Commit cef23f8

Browse files
authored
fix: chrono deprecation warnings (#558)
Fixes `chrono` deprecation warnings introduced in 0.4.35.
1 parent a0e4647 commit cef23f8

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bytes = "1.5.0"
4343
bzip2 = "0.4.4"
4444
cache_control = "0.2.0"
4545
cfg-if = "1.0"
46-
chrono = { version = "0.4.34", default-features = false, features = [
46+
chrono = { version = "0.4.35", default-features = false, features = [
4747
"std",
4848
"serde",
4949
"alloc",

crates/rattler_conda_types/src/utils/serde.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@ impl<'de> DeserializeAs<'de, chrono::DateTime<chrono::Utc>> for Timestamp {
117117
};
118118

119119
// Convert the timestamp to a UTC timestamp
120-
Ok(chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(
121-
chrono::NaiveDateTime::from_timestamp_micros(microseconds)
122-
.ok_or_else(|| D::Error::custom("got invalid timestamp, timestamp out of range"))?,
123-
chrono::Utc,
124-
))
120+
chrono::DateTime::from_timestamp_micros(microseconds)
121+
.ok_or_else(|| D::Error::custom("got invalid timestamp, timestamp out of range"))
125122
}
126123
}
127124

crates/rattler_lock/src/utils/serde/timestamp.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ impl<'de> DeserializeAs<'de, chrono::DateTime<chrono::Utc>> for Timestamp {
2020
};
2121

2222
// Convert the timestamp to a UTC timestamp
23-
Ok(chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(
24-
chrono::NaiveDateTime::from_timestamp_micros(microseconds)
25-
.ok_or_else(|| D::Error::custom("got invalid timestamp, timestamp out of range"))?,
26-
chrono::Utc,
27-
))
23+
chrono::DateTime::from_timestamp_micros(microseconds)
24+
.ok_or_else(|| D::Error::custom("got invalid timestamp, timestamp out of range"))
2825
}
2926
}
3027

crates/rattler_repodata_gateway/src/fetch/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ async fn repodata_from_file(
315315
///
316316
/// The checks to see if a `.zst` and/or `.bz2` file exist are performed by doing a HEAD request to
317317
/// the respective URLs. The result of these are cached.
318-
#[instrument(err, skip_all, fields(subdir_url, cache_path = %cache_path.display()))]
318+
#[instrument(err, skip_all, fields(subdir_url, cache_path = % cache_path.display()))]
319319
pub async fn fetch_repo_data(
320320
subdir_url: Url,
321321
client: reqwest_middleware::ClientWithMiddleware,
@@ -441,7 +441,7 @@ pub async fn fetch_repo_data(
441441
has_bz2: variant_availability.has_bz2,
442442
has_jlap: variant_availability.has_jlap,
443443
jlap: Some(state),
444-
.. cache_state.expect("we must have had a cache, otherwise we wouldn't know the previous state of the cache")
444+
..cache_state.expect("we must have had a cache, otherwise we wouldn't know the previous state of the cache")
445445
};
446446

447447
let cache_state = tokio::task::spawn_blocking(move || {
@@ -528,7 +528,7 @@ pub async fn fetch_repo_data(
528528
has_bz2: variant_availability.has_bz2,
529529
has_jlap: variant_availability.has_jlap,
530530
jlap: jlap_state,
531-
.. cache_state.expect("we must have had a cache, otherwise we wouldn't know the previous state of the cache")
531+
..cache_state.expect("we must have had a cache, otherwise we wouldn't know the previous state of the cache")
532532
};
533533

534534
let cache_state = tokio::task::spawn_blocking(move || {
@@ -737,7 +737,7 @@ pub async fn check_variant_availability(
737737
) -> VariantAvailability {
738738
// Determine from the cache which variant are available. This is currently cached for a maximum
739739
// of 14 days.
740-
let expiration_duration = chrono::Duration::days(14);
740+
let expiration_duration = chrono::TimeDelta::try_days(14).expect("14 days is a valid duration");
741741
let has_zst = cache_state
742742
.and_then(|state| state.has_zst.as_ref())
743743
.and_then(|value| value.value(expiration_duration))

0 commit comments

Comments
 (0)