Skip to content

Commit

Permalink
Replace .and_local_timezone(Utc) with .and_utc()
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Mar 18, 2024
1 parent c2f3132 commit 4d0f580
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/datetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl<Tz: TimeZone> DateTime<Tz> {
/// .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");
Expand Down
24 changes: 12 additions & 12 deletions src/datetime/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'de> de::Deserialize<'de> for DateTime<Local> {
/// .unwrap()
/// .at_hms_nano(02, 04, 59, 918355733)
/// .unwrap()
/// .and_local_timezone(Utc)
/// .and_utc()
/// .unwrap();
/// let my_s = S { time: time.clone() };
///
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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() };
Expand Down Expand Up @@ -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(),
/// ),
/// };
Expand Down Expand Up @@ -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() };
///
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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() };
Expand Down Expand Up @@ -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(),
/// ),
/// };
Expand Down Expand Up @@ -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() };
///
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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() };
Expand Down Expand Up @@ -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(),
/// ),
/// };
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")))]
Expand Down
2 changes: 1 addition & 1 deletion src/naive/datetime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/naive/time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/// ```
Expand Down Expand Up @@ -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");
/// ```
Expand Down
10 changes: 5 additions & 5 deletions src/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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!(
Expand Down

0 comments on commit 4d0f580

Please sign in to comment.