Update deprecated methods in from_utc example

`from_timestamp` and `Utc.timestamp` are deprecated, and have been replaced with `from_timestamp_opt` and `Utc.timestamp_opt` respectively, with unwrapping.
This commit is contained in:
Greg Leonard 2023-01-18 18:46:12 +00:00 committed by Dirkjan Ochtman
parent 7c5e631fde
commit b244b83a64

View File

@ -107,8 +107,8 @@ impl<Tz: TimeZone> DateTime<Tz> {
/// ```
/// use chrono::{DateTime, TimeZone, NaiveDateTime, Utc};
///
/// let dt = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(61, 0), Utc);
/// assert_eq!(Utc.timestamp(61, 0), dt);
/// let dt = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp_opt(61, 0).unwrap(), Utc);
/// assert_eq!(Utc.timestamp_opt(61, 0).unwrap(), dt);
/// ```
//
// note: this constructor is purposely not named to `new` to discourage the direct usage.