diff --git a/src/datetime/mod.rs b/src/datetime/mod.rs index b63ee25b14..f16e19627e 100644 --- a/src/datetime/mod.rs +++ b/src/datetime/mod.rs @@ -532,7 +532,7 @@ impl DateTime { /// .unwrap() /// .at_hms_micro(18, 30, 9, 453_829) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(); /// assert_eq!(dt.to_rfc3339_opts(SecondsFormat::Millis, false), "2018-01-26T18:30:09.453+00:00"); /// assert_eq!(dt.to_rfc3339_opts(SecondsFormat::Millis, true), "2018-01-26T18:30:09.453Z"); diff --git a/src/datetime/serde.rs b/src/datetime/serde.rs index 6a418fa193..b2e51e99ce 100644 --- a/src/datetime/serde.rs +++ b/src/datetime/serde.rs @@ -117,7 +117,7 @@ impl<'de> de::Deserialize<'de> for DateTime { /// .unwrap() /// .at_hms_nano(02, 04, 59, 918355733) /// .unwrap() -/// .and_local_timezone(Utc) +/// .and_utc() /// .unwrap(); /// let my_s = S { time: time.clone() }; /// @@ -163,7 +163,7 @@ pub mod ts_nanoseconds { /// .unwrap() /// .at_hms_nano(02, 04, 59, 918355733) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(), /// }; /// let as_string = serde_json::to_string(&my_s)?; @@ -262,7 +262,7 @@ pub mod ts_nanoseconds { /// .unwrap() /// .at_hms_nano(02, 04, 59, 918355733) /// .unwrap() -/// .and_local_timezone(Utc) +/// .and_utc() /// .unwrap(), /// ); /// let my_s = S { time: time.clone() }; @@ -311,7 +311,7 @@ pub mod ts_nanoseconds_option { /// .unwrap() /// .at_hms_nano(02, 04, 59, 918355733) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(), /// ), /// }; @@ -413,7 +413,7 @@ pub mod ts_nanoseconds_option { /// .unwrap() /// .at_hms_micro(02, 04, 59, 918355) /// .unwrap() -/// .and_local_timezone(Utc) +/// .and_utc() /// .unwrap(); /// let my_s = S { time: time.clone() }; /// @@ -451,7 +451,7 @@ pub mod ts_microseconds { /// .unwrap() /// .at_hms_micro(02, 04, 59, 918355) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(), /// }; /// let as_string = serde_json::to_string(&my_s)?; @@ -551,7 +551,7 @@ pub mod ts_microseconds { /// .unwrap() /// .at_hms_micro(02, 04, 59, 918355) /// .unwrap() -/// .and_local_timezone(Utc) +/// .and_utc() /// .unwrap(), /// ); /// let my_s = S { time: time.clone() }; @@ -591,7 +591,7 @@ pub mod ts_microseconds_option { /// .unwrap() /// .at_hms_micro(02, 04, 59, 918355) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(), /// ), /// }; @@ -691,7 +691,7 @@ pub mod ts_microseconds_option { /// .unwrap() /// .at_hms_milli(02, 04, 59, 918) /// .unwrap() -/// .and_local_timezone(Utc) +/// .and_utc() /// .unwrap(); /// let my_s = S { time: time.clone() }; /// @@ -729,7 +729,7 @@ pub mod ts_milliseconds { /// .unwrap() /// .at_hms_milli(02, 04, 59, 918) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(), /// }; /// let as_string = serde_json::to_string(&my_s)?; @@ -822,7 +822,7 @@ pub mod ts_milliseconds { /// .unwrap() /// .at_hms_milli(02, 04, 59, 918) /// .unwrap() -/// .and_local_timezone(Utc) +/// .and_utc() /// .unwrap(), /// ); /// let my_s = S { time: time.clone() }; @@ -862,7 +862,7 @@ pub mod ts_milliseconds_option { /// .unwrap() /// .at_hms_milli(02, 04, 59, 918) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(), /// ), /// }; diff --git a/src/lib.rs b/src/lib.rs index 52f22385bc..1274779ea5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -135,16 +135,16 @@ //! # fn doctest() -> Option<()> { //! //! let dt = Utc.at_ymd_and_hms(2014, 7, 8, 9, 10, 11).unwrap(); // `2014-07-08T09:10:11Z` -//! assert_eq!(dt, NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms(9, 10, 11).unwrap().and_local_timezone(Utc).unwrap()); +//! assert_eq!(dt, NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms(9, 10, 11).unwrap().and_utc().unwrap()); //! //! // July 8 is 188th day of the year 2014 (`o` for "ordinal") //! assert_eq!(dt, NaiveDate::from_yo(2014, 189).unwrap().at_hms(9, 10, 11).unwrap().and_utc()); //! // July 8 is Tuesday in ISO week 28 of the year 2014. //! assert_eq!(dt, NaiveDate::from_isoywd(2014, 28, Weekday::Tue).unwrap().at_hms(9, 10, 11).unwrap().and_utc()); //! -//! let dt = NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms_milli(9, 10, 11, 12).unwrap().and_local_timezone(Utc).unwrap(); // `2014-07-08T09:10:11.012Z` -//! assert_eq!(dt, NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms_micro(9, 10, 11, 12_000).unwrap().and_local_timezone(Utc).unwrap()); -//! assert_eq!(dt, NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms_nano(9, 10, 11, 12_000_000).unwrap().and_local_timezone(Utc).unwrap()); +//! let dt = NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms_milli(9, 10, 11, 12).unwrap().and_utc().unwrap(); // `2014-07-08T09:10:11.012Z` +//! assert_eq!(dt, NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms_micro(9, 10, 11, 12_000).unwrap().and_utc().unwrap()); +//! assert_eq!(dt, NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms_nano(9, 10, 11, 12_000_000).unwrap().and_utc().unwrap()); //! //! // dynamic verification //! assert_eq!( @@ -193,7 +193,7 @@ //! // time zone accessor and manipulation //! assert_eq!(dt.offset().fix().local_minus_utc(), 9 * 3600); //! assert_eq!(dt.timezone(), FixedOffset::east(9 * 3600).unwrap()); -//! assert_eq!(dt.with_timezone(&Utc), NaiveDate::from_ymd(2014, 11, 28).unwrap().at_hms_nano(12, 45, 59, 324310806).unwrap().and_local_timezone(Utc).unwrap()); +//! assert_eq!(dt.with_timezone(&Utc), NaiveDate::from_ymd(2014, 11, 28).unwrap().at_hms_nano(12, 45, 59, 324310806).unwrap().and_utc().unwrap()); //! //! // a sample of property manipulations (validates dynamically) //! assert_eq!(dt.with_day(29).unwrap().weekday(), Weekday::Sat); // 2014-11-29 is Saturday @@ -256,7 +256,7 @@ //! assert_eq!(format!("{:?}", dt), "2014-11-28T12:00:09Z"); //! //! // Note that milli/nanoseconds are only printed if they are non-zero -//! let dt_nano = NaiveDate::from_ymd(2014, 11, 28).unwrap().at_hms_nano(12, 0, 9, 1).unwrap().and_local_timezone(Utc).unwrap(); +//! let dt_nano = NaiveDate::from_ymd(2014, 11, 28).unwrap().at_hms_nano(12, 0, 9, 1).unwrap().and_utc().unwrap(); //! assert_eq!(format!("{:?}", dt_nano), "2014-11-28T12:00:09.000000001Z"); //! # } //! # #[cfg(not(all(feature = "unstable-locales", feature = "alloc")))] diff --git a/src/naive/datetime/tests.rs b/src/naive/datetime/tests.rs index 5f4db11c16..a652d51360 100644 --- a/src/naive/datetime/tests.rs +++ b/src/naive/datetime/tests.rs @@ -271,7 +271,7 @@ fn test_datetime_add_sub_invariant() { #[test] fn test_and_local_timezone() { let ndt = NaiveDate::from_ymd(2022, 6, 15).unwrap().at_hms(18, 59, 36).unwrap(); - let dt_utc = ndt.and_local_timezone(Utc).unwrap(); + let dt_utc = ndt.and_utc().unwrap(); assert_eq!(dt_utc.naive_local(), ndt); assert_eq!(dt_utc.timezone(), Utc); diff --git a/src/naive/time/mod.rs b/src/naive/time/mod.rs index 5ec08af4dd..0b3c6ae3a1 100644 --- a/src/naive/time/mod.rs +++ b/src/naive/time/mod.rs @@ -83,7 +83,7 @@ mod tests; /// .unwrap() /// .at_hms_nano(23, 59, 59, 1_000_000_000) /// .unwrap() -/// .and_local_timezone(Utc) +/// .and_utc() /// .unwrap(); /// # let _ = (t, dt1, dt2); /// ``` @@ -172,7 +172,7 @@ mod tests; /// .unwrap() /// .at_hms_milli(23, 59, 59, 1_000) /// .unwrap() -/// .and_local_timezone(Utc) +/// .and_utc() /// .unwrap(); /// assert_eq!(format!("{:?}", dt), "2015-06-30T23:59:60Z"); /// ``` diff --git a/src/round.rs b/src/round.rs index 1cd3362ac4..64c29f7aa1 100644 --- a/src/round.rs +++ b/src/round.rs @@ -26,7 +26,7 @@ pub trait SubsecRound { /// .unwrap() /// .at_hms_milli(12, 0, 0, 154) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(); /// assert_eq!(dt.round_subsecs(2).nanosecond(), 150_000_000); /// assert_eq!(dt.round_subsecs(1).nanosecond(), 200_000_000); @@ -43,7 +43,7 @@ pub trait SubsecRound { /// .unwrap() /// .at_hms_milli(12, 0, 0, 154) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(); /// assert_eq!(dt.trunc_subsecs(2).nanosecond(), 150_000_000); /// assert_eq!(dt.trunc_subsecs(1).nanosecond(), 100_000_000); @@ -123,7 +123,7 @@ pub trait DurationRound: Sized { /// .unwrap() /// .at_hms_milli(12, 0, 0, 154) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(); /// assert_eq!( /// dt.duration_round(TimeDelta::milliseconds(10).unwrap()).unwrap().to_string(), @@ -145,7 +145,7 @@ pub trait DurationRound: Sized { /// .unwrap() /// .at_hms_milli(12, 0, 0, 154) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(); /// assert_eq!( /// dt.duration_trunc(TimeDelta::milliseconds(10).unwrap()).unwrap().to_string(), @@ -263,7 +263,7 @@ pub enum RoundingError { /// .unwrap() /// .at_hms_nano(23, 59, 59, 1_75_500_000) /// .unwrap() - /// .and_local_timezone(Utc) + /// .and_utc() /// .unwrap(); /// /// assert_eq!(