Skip to content

Commit

Permalink
Replace calls to deprecated functions with a recommended replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
andy128k committed Nov 15, 2024
1 parent 886878e commit 1975e76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn rfc2822<T: AsRef<str>>(string: T) -> Option<DateTime<FixedOffset>> {

fn utc_datetime(string: &str, format: &str) -> Option<DateTime<FixedOffset>> {
NaiveDateTime::parse_from_str(string, format)
.map(|d| DateTime::from_utc(d, Utc))
.map(|d| Utc.from_utc_datetime(&d))
.ok()
.map(|d: DateTime<Utc>| d.into())
}
Expand All @@ -63,7 +63,7 @@ fn utc_date(string: &str, format: &str) -> Option<DateTime<FixedOffset>> {
let date = NaiveDate::parse_from_str(string, format).ok()?;
let time = NaiveTime::from_hms_opt(0, 0, 0)?;
let datetime = NaiveDateTime::new(date, time);
Some(DateTime::<Utc>::from_utc(datetime, Utc).into())
Some(Utc.from_utc_datetime(&datetime).into())
}

/// Parses a string using multiple formats
Expand Down

0 comments on commit 1975e76

Please sign in to comment.