diff --git a/src/datetime/mod.rs b/src/datetime/mod.rs index e418510be7..16ecc41511 100644 --- a/src/datetime/mod.rs +++ b/src/datetime/mod.rs @@ -151,10 +151,10 @@ impl DateTime { /// ``` /// use chrono::NaiveDate; /// - /// let dt = NaiveDate::from_ymd(1970, 1, 1)?.at_hms_milli(0, 0, 1, 444)?.and_utc(); + /// let dt = NaiveDate::from_ymd(1970, 1, 1)?.at_hms_milli(0, 0, 1, 444)?.in_utc(); /// assert_eq!(dt.timestamp_millis(), 1_444); /// - /// let dt = NaiveDate::from_ymd(2001, 9, 9)?.at_hms_milli(1, 46, 40, 555)?.and_utc(); + /// let dt = NaiveDate::from_ymd(2001, 9, 9)?.at_hms_milli(1, 46, 40, 555)?.in_utc(); /// assert_eq!(dt.timestamp_millis(), 1_000_000_000_555); /// # Ok::<(), chrono::Error>(()) /// ``` @@ -172,10 +172,10 @@ impl DateTime { /// ``` /// use chrono::NaiveDate; /// - /// let dt = NaiveDate::from_ymd(1970, 1, 1)?.at_hms_micro(0, 0, 1, 444)?.and_utc(); + /// let dt = NaiveDate::from_ymd(1970, 1, 1)?.at_hms_micro(0, 0, 1, 444)?.in_utc(); /// assert_eq!(dt.timestamp_micros(), 1_000_444); /// - /// let dt = NaiveDate::from_ymd(2001, 9, 9)?.at_hms_micro(1, 46, 40, 555)?.and_utc(); + /// let dt = NaiveDate::from_ymd(2001, 9, 9)?.at_hms_micro(1, 46, 40, 555)?.in_utc(); /// assert_eq!(dt.timestamp_micros(), 1_000_000_000_000_555); /// # Ok::<(), chrono::Error>(()) /// ``` @@ -201,22 +201,22 @@ impl DateTime { /// ``` /// use chrono::{Error, NaiveDate}; /// - /// let dt = NaiveDate::from_ymd(1970, 1, 1)?.at_hms_nano(0, 0, 1, 444)?.and_utc(); + /// let dt = NaiveDate::from_ymd(1970, 1, 1)?.at_hms_nano(0, 0, 1, 444)?.in_utc(); /// assert_eq!(dt.timestamp_nanos(), Ok(1_000_000_444)); /// - /// let dt = NaiveDate::from_ymd(2001, 9, 9)?.at_hms_nano(1, 46, 40, 555)?.and_utc(); + /// let dt = NaiveDate::from_ymd(2001, 9, 9)?.at_hms_nano(1, 46, 40, 555)?.in_utc(); /// assert_eq!(dt.timestamp_nanos(), Ok(1_000_000_000_000_000_555)); /// - /// let dt = NaiveDate::from_ymd(1677, 9, 21)?.at_hms_nano(0, 12, 43, 145_224_192)?.and_utc(); + /// let dt = NaiveDate::from_ymd(1677, 9, 21)?.at_hms_nano(0, 12, 43, 145_224_192)?.in_utc(); /// assert_eq!(dt.timestamp_nanos(), Ok(-9_223_372_036_854_775_808)); /// - /// let dt = NaiveDate::from_ymd(2262, 4, 11)?.at_hms_nano(23, 47, 16, 854_775_807)?.and_utc(); + /// let dt = NaiveDate::from_ymd(2262, 4, 11)?.at_hms_nano(23, 47, 16, 854_775_807)?.in_utc(); /// assert_eq!(dt.timestamp_nanos(), Ok(9_223_372_036_854_775_807)); /// - /// let dt = NaiveDate::from_ymd(1677, 9, 21)?.at_hms_nano(0, 12, 43, 145_224_191)?.and_utc(); + /// let dt = NaiveDate::from_ymd(1677, 9, 21)?.at_hms_nano(0, 12, 43, 145_224_191)?.in_utc(); /// assert_eq!(dt.timestamp_nanos(), Err(Error::OutOfRange)); /// - /// let dt = NaiveDate::from_ymd(2262, 4, 11)?.at_hms_nano(23, 47, 16, 854_775_808)?.and_utc(); + /// let dt = NaiveDate::from_ymd(2262, 4, 11)?.at_hms_nano(23, 47, 16, 854_775_808)?.in_utc(); /// assert_eq!(dt.timestamp_nanos(), Err(Error::OutOfRange)); /// # Ok::<(), Error>(()) /// ``` @@ -532,7 +532,7 @@ impl DateTime { /// .unwrap() /// .at_hms_micro(18, 30, 9, 453_829) /// .unwrap() - /// .and_utc() + /// .in_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"); @@ -761,7 +761,7 @@ impl DateTime { } let date = try_err!(NaiveDate::from_num_days_from_ce(days as i32)); let time = try_err!(NaiveTime::from_num_seconds_from_midnight(secs as u32, nsecs)); - Ok(date.at(time).and_utc()) + Ok(date.at(time).in_utc()) } /// Makes a new `DateTime` from the number of non-leap milliseconds diff --git a/src/datetime/serde.rs b/src/datetime/serde.rs index b2e51e99ce..37d60fa2bf 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_utc() +/// .in_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_utc() + /// .in_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_utc() +/// .in_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_utc() + /// .in_utc() /// .unwrap(), /// ), /// }; @@ -413,7 +413,7 @@ pub mod ts_nanoseconds_option { /// .unwrap() /// .at_hms_micro(02, 04, 59, 918355) /// .unwrap() -/// .and_utc() +/// .in_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_utc() + /// .in_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_utc() +/// .in_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_utc() + /// .in_utc() /// .unwrap(), /// ), /// }; @@ -691,7 +691,7 @@ pub mod ts_microseconds_option { /// .unwrap() /// .at_hms_milli(02, 04, 59, 918) /// .unwrap() -/// .and_utc() +/// .in_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_utc() + /// .in_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_utc() +/// .in_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_utc() + /// .in_utc() /// .unwrap(), /// ), /// }; diff --git a/src/datetime/tests.rs b/src/datetime/tests.rs index e47dc4be84..122f21a6a2 100644 --- a/src/datetime/tests.rs +++ b/src/datetime/tests.rs @@ -245,7 +245,7 @@ fn test_datetime_from_timestamp_nanos() { fn test_datetime_from_timestamp() { let from_timestamp = |secs| DateTime::from_timestamp(secs, 0); let ymdhms = - |y, m, d, h, n, s| NaiveDate::from_ymd(y, m, d).unwrap().at_hms(h, n, s).unwrap().and_utc(); + |y, m, d, h, n, s| NaiveDate::from_ymd(y, m, d).unwrap().at_hms(h, n, s).unwrap().in_utc(); assert_eq!(from_timestamp(-1), Ok(ymdhms(1969, 12, 31, 23, 59, 59))); assert_eq!(from_timestamp(0), Ok(ymdhms(1970, 1, 1, 0, 0, 0))); assert_eq!(from_timestamp(1), Ok(ymdhms(1970, 1, 1, 0, 0, 1))); @@ -258,7 +258,7 @@ fn test_datetime_from_timestamp() { #[test] fn test_datetime_timestamp() { let to_timestamp = |y, m, d, h, n, s| { - NaiveDate::from_ymd(y, m, d).unwrap().at_hms(h, n, s).unwrap().and_utc().timestamp() + NaiveDate::from_ymd(y, m, d).unwrap().at_hms(h, n, s).unwrap().in_utc().timestamp() }; assert_eq!(to_timestamp(1969, 12, 31, 23, 59, 59), -1); assert_eq!(to_timestamp(1970, 1, 1, 0, 0, 0), 0); @@ -841,7 +841,7 @@ fn test_rfc3339_opts() { assert_eq!(dt.to_rfc3339_opts(Nanos, false), "2018-01-11T10:05:13.084660000+08:00"); assert_eq!(dt.to_rfc3339_opts(AutoSi, false), "2018-01-11T10:05:13.084660+08:00"); - let ut = dt.naive_utc().and_utc(); + let ut = dt.naive_utc().in_utc(); assert_eq!(ut.to_rfc3339_opts(Secs, false), "2018-01-11T02:05:13+00:00"); assert_eq!(ut.to_rfc3339_opts(Secs, true), "2018-01-11T02:05:13Z"); assert_eq!(ut.to_rfc3339_opts(Millis, false), "2018-01-11T02:05:13.084+00:00"); @@ -1379,7 +1379,7 @@ fn test_years_elapsed() { #[test] fn test_datetime_add_assign() { let naivedatetime = NaiveDate::from_ymd(2000, 1, 1).unwrap().at_hms(0, 0, 0).unwrap(); - let datetime = naivedatetime.and_utc(); + let datetime = naivedatetime.in_utc(); let mut datetime_add = datetime; datetime_add += TimeDelta::seconds(60); @@ -1416,7 +1416,7 @@ fn test_datetime_add_assign_local() { #[test] fn test_datetime_sub_assign() { let naivedatetime = NaiveDate::from_ymd(2000, 1, 1).unwrap().at_hms(12, 0, 0).unwrap(); - let datetime = naivedatetime.and_utc(); + let datetime = naivedatetime.in_utc(); let mut datetime_sub = datetime; datetime_sub -= TimeDelta::minutes(90); diff --git a/src/format/formatting.rs b/src/format/formatting.rs index 0c7a3e70bc..a349902365 100644 --- a/src/format/formatting.rs +++ b/src/format/formatting.rs @@ -182,9 +182,9 @@ fn format_inner( Timestamp => ( 1, match (date, time, off) { - (Some(d), Some(t), None) => Some(d.at(*t).and_utc().timestamp()), + (Some(d), Some(t), None) => Some(d.at(*t).in_utc().timestamp()), (Some(d), Some(t), Some(&(_, off))) => { - Some(d.at(*t).and_utc().timestamp() - i64::from(off.local_minus_utc())) + Some(d.at(*t).in_utc().timestamp() - i64::from(off.local_minus_utc())) } (_, _, _) => None, }, diff --git a/src/format/mod.rs b/src/format/mod.rs index f8ed9bc80b..a8de2692ae 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -25,7 +25,7 @@ //! let formatted = format!("{}", date_time.format("%Y-%m-%d %H:%M:%S")); //! assert_eq!(formatted, "2020-11-10 00:01:32"); //! -//! let parsed = NaiveDateTime::parse_from_str(&formatted, "%Y-%m-%d %H:%M:%S")?.and_utc(); +//! let parsed = NaiveDateTime::parse_from_str(&formatted, "%Y-%m-%d %H:%M:%S")?.in_utc(); //! assert_eq!(parsed, date_time); //! # Ok::<(), chrono::ParseError>(()) //! ``` diff --git a/src/format/parsed.rs b/src/format/parsed.rs index 8b82ef5681..7f4a8f4475 100644 --- a/src/format/parsed.rs +++ b/src/format/parsed.rs @@ -754,7 +754,7 @@ impl Parsed { // verify the timestamp field if any // the following is safe, `timestamp` is very limited in range - let timestamp = datetime.and_utc().timestamp() - i64::from(offset); + let timestamp = datetime.in_utc().timestamp() - i64::from(offset); if let Some(given_timestamp) = self.timestamp { // if `datetime` represents a leap second, it might be off by one second. if given_timestamp != timestamp diff --git a/src/lib.rs b/src/lib.rs index 1274779ea5..1471dd896a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -135,22 +135,22 @@ //! # 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_utc().unwrap()); +//! assert_eq!(dt, NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms(9, 10, 11).unwrap().in_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()); +//! assert_eq!(dt, NaiveDate::from_yo(2014, 189).unwrap().at_hms(9, 10, 11).unwrap().in_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()); +//! assert_eq!(dt, NaiveDate::from_isoywd(2014, 28, Weekday::Tue).unwrap().at_hms(9, 10, 11).unwrap().in_utc()); //! -//! 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()); +//! let dt = NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms_milli(9, 10, 11, 12).unwrap().in_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().in_utc().unwrap()); +//! assert_eq!(dt, NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms_nano(9, 10, 11, 12_000_000).unwrap().in_utc().unwrap()); //! //! // dynamic verification //! assert_eq!( //! Utc.at_ymd_and_hms(2014, 7, 8, 21, 15, 33), //! MappedLocalTime::Single( -//! NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms(21, 15, 33).unwrap().and_utc() +//! NaiveDate::from_ymd(2014, 7, 8).unwrap().at_hms(21, 15, 33).unwrap().in_utc() //! ) //! ); //! assert_eq!(Utc.at_ymd_and_hms(2014, 7, 8, 80, 15, 33), MappedLocalTime::None); @@ -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_utc().unwrap()); +//! assert_eq!(dt.with_timezone(&Utc), NaiveDate::from_ymd(2014, 11, 28).unwrap().at_hms_nano(12, 45, 59, 324310806).unwrap().in_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_utc().unwrap(); +//! let dt_nano = NaiveDate::from_ymd(2014, 11, 28).unwrap().at_hms_nano(12, 0, 9, 1).unwrap().in_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/mod.rs b/src/naive/datetime/mod.rs index a6c1153640..d223b3bfc3 100644 --- a/src/naive/datetime/mod.rs +++ b/src/naive/datetime/mod.rs @@ -716,11 +716,11 @@ impl NaiveDateTime { /// /// ``` /// use chrono::{NaiveDate, Utc}; - /// let dt = NaiveDate::from_ymd(2023, 1, 30).unwrap().at_hms(19, 32, 33).unwrap().and_utc(); + /// let dt = NaiveDate::from_ymd(2023, 1, 30).unwrap().at_hms(19, 32, 33).unwrap().in_utc(); /// assert_eq!(dt.timezone(), Utc); /// ``` #[must_use] - pub const fn and_utc(self) -> DateTime { + pub const fn in_utc(self) -> DateTime { DateTime::from_naive_utc_and_offset(self, Utc) } diff --git a/src/naive/datetime/serde.rs b/src/naive/datetime/serde.rs index 87c9cda64c..0d6ec452e0 100644 --- a/src/naive/datetime/serde.rs +++ b/src/naive/datetime/serde.rs @@ -118,7 +118,7 @@ pub mod ts_nanoseconds { where S: ser::Serializer, { - serializer.serialize_i64(dt.and_utc().timestamp_nanos().map_err(|_| { + serializer.serialize_i64(dt.in_utc().timestamp_nanos().map_err(|_| { ser::Error::custom("value out of range for a timestamp with nanosecond precision") })?) } @@ -259,7 +259,7 @@ pub mod ts_nanoseconds_option { { match *opt { Some(ref dt) => { - serializer.serialize_some(&dt.and_utc().timestamp_nanos().map_err(|_| { + serializer.serialize_some(&dt.in_utc().timestamp_nanos().map_err(|_| { ser::Error::custom( "value out of range for a timestamp with nanosecond precision", ) @@ -393,7 +393,7 @@ pub mod ts_microseconds { where S: ser::Serializer, { - serializer.serialize_i64(dt.and_utc().timestamp_micros()) + serializer.serialize_i64(dt.in_utc().timestamp_micros()) } /// Deserialize a `NaiveDateTime` from a microseconds timestamp @@ -523,7 +523,7 @@ pub mod ts_microseconds_option { S: ser::Serializer, { match *opt { - Some(ref dt) => serializer.serialize_some(&dt.and_utc().timestamp_micros()), + Some(ref dt) => serializer.serialize_some(&dt.in_utc().timestamp_micros()), None => serializer.serialize_none(), } } @@ -652,7 +652,7 @@ pub mod ts_milliseconds { where S: ser::Serializer, { - serializer.serialize_i64(dt.and_utc().timestamp_millis()) + serializer.serialize_i64(dt.in_utc().timestamp_millis()) } /// Deserialize a `NaiveDateTime` from a milliseconds timestamp @@ -779,7 +779,7 @@ pub mod ts_milliseconds_option { S: ser::Serializer, { match *opt { - Some(ref dt) => serializer.serialize_some(&dt.and_utc().timestamp_millis()), + Some(ref dt) => serializer.serialize_some(&dt.in_utc().timestamp_millis()), None => serializer.serialize_none(), } } @@ -906,7 +906,7 @@ pub mod ts_seconds { where S: ser::Serializer, { - serializer.serialize_i64(dt.and_utc().timestamp()) + serializer.serialize_i64(dt.in_utc().timestamp()) } /// Deserialize a `NaiveDateTime` from a seconds timestamp @@ -1029,7 +1029,7 @@ pub mod ts_seconds_option { S: ser::Serializer, { match *opt { - Some(ref dt) => serializer.serialize_some(&dt.and_utc().timestamp()), + Some(ref dt) => serializer.serialize_some(&dt.in_utc().timestamp()), None => serializer.serialize_none(), } } diff --git a/src/naive/datetime/tests.rs b/src/naive/datetime/tests.rs index d5c66fa609..5622e46c3d 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_in_timezone() { let ndt = NaiveDate::from_ymd(2022, 6, 15).unwrap().at_hms(18, 59, 36).unwrap(); - let dt_utc = ndt.and_utc().unwrap(); + let dt_utc = ndt.in_utc().unwrap(); assert_eq!(dt_utc.naive_local(), ndt); assert_eq!(dt_utc.timezone(), Utc); @@ -282,9 +282,9 @@ fn test_in_timezone() { } #[test] -fn test_and_utc() { +fn test_in_utc() { let ndt = NaiveDate::from_ymd(2023, 1, 30).unwrap().at_hms(19, 32, 33).unwrap(); - let dt_utc = ndt.and_utc(); + let dt_utc = ndt.in_utc(); 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 0b3c6ae3a1..86196cb502 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_utc() +/// .in_utc() /// .unwrap(); /// # let _ = (t, dt1, dt2); /// ``` @@ -172,7 +172,7 @@ mod tests; /// .unwrap() /// .at_hms_milli(23, 59, 59, 1_000) /// .unwrap() -/// .and_utc() +/// .in_utc() /// .unwrap(); /// assert_eq!(format!("{:?}", dt), "2015-06-30T23:59:60Z"); /// ``` diff --git a/src/offset/local/mod.rs b/src/offset/local/mod.rs index ec996a4a45..4b209a7f36 100644 --- a/src/offset/local/mod.rs +++ b/src/offset/local/mod.rs @@ -59,7 +59,7 @@ mod inner { use crate::{Datelike, FixedOffset, MappedLocalTime, NaiveDateTime, Timelike}; pub(super) fn offset_from_utc_datetime(utc: NaiveDateTime) -> MappedLocalTime { - let offset = js_sys::Date::from(utc.and_utc()).get_timezone_offset(); + let offset = js_sys::Date::from(utc.in_utc()).get_timezone_offset(); MappedLocalTime::Single(FixedOffset::west((offset as i32) * 60).unwrap()) } diff --git a/src/offset/local/unix.rs b/src/offset/local/unix.rs index 840ac3f3d7..6168476c56 100644 --- a/src/offset/local/unix.rs +++ b/src/offset/local/unix.rs @@ -151,7 +151,7 @@ impl Cache { if !local { let offset = self .zone - .find_local_time_type(d.and_utc().timestamp()) + .find_local_time_type(d.in_utc().timestamp()) .expect("unable to select local time type") .offset(); @@ -164,7 +164,7 @@ impl Cache { // we pass through the year as the year of a local point in time must either be valid in that locale, or // the entire time was skipped in which case we will return MappedLocalTime::None anyway. self.zone - .find_local_time_type_from_local(d.and_utc().timestamp(), d.year()) + .find_local_time_type_from_local(d.in_utc().timestamp(), d.year()) .expect("unable to select local time type") .map(|o| FixedOffset::east(o.offset()).unwrap()) } diff --git a/src/round.rs b/src/round.rs index 64c29f7aa1..74909ba31f 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_utc() + /// .in_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_utc() + /// .in_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_utc() + /// .in_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_utc() + /// .in_utc() /// .unwrap(); /// assert_eq!( /// dt.duration_trunc(TimeDelta::milliseconds(10).unwrap()).unwrap().to_string(), @@ -196,7 +196,7 @@ where return Err(RoundingError::DurationExceedsLimit); } let stamp = - naive.and_utc().timestamp_nanos().map_err(|_| RoundingError::TimestampExceedsLimit)?; + naive.in_utc().timestamp_nanos().map_err(|_| RoundingError::TimestampExceedsLimit)?; if span == 0 { return Ok(original); } @@ -233,7 +233,7 @@ where return Err(RoundingError::DurationExceedsLimit); } let stamp = - naive.and_utc().timestamp_nanos().map_err(|_| RoundingError::TimestampExceedsLimit)?; + naive.in_utc().timestamp_nanos().map_err(|_| RoundingError::TimestampExceedsLimit)?; let delta_down = stamp % span; match delta_down.cmp(&0) { Ordering::Equal => Ok(original), @@ -263,7 +263,7 @@ pub enum RoundingError { /// .unwrap() /// .at_hms_nano(23, 59, 59, 1_75_500_000) /// .unwrap() - /// .and_utc() + /// .in_utc() /// .unwrap(); /// /// assert_eq!( diff --git a/tests/wasm.rs b/tests/wasm.rs index 7eea86b633..28e6d6ade6 100644 --- a/tests/wasm.rs +++ b/tests/wasm.rs @@ -22,7 +22,7 @@ fn now() { // Ensure time set by the test script is correct let now = env!("NOW"); - let actual = NaiveDateTime::parse_from_str(&now, "%s").unwrap().and_utc(); + let actual = NaiveDateTime::parse_from_str(&now, "%s").unwrap().in_utc(); let diff = utc - actual; assert!( diff < chrono::TimeDelta::minutes(5),