Revert "Add with_timezone to NaiveDateTime"

This reverts commit e9067a5a3e684f1069f9d627e57ea7d536398e2e.
This commit is contained in:
Paul Dicker 2023-04-19 18:08:00 +02:00 committed by Dirkjan Ochtman
parent e3bca27a01
commit a20a9b7b90

View File

@ -554,28 +554,6 @@ impl NaiveDateTime {
self.time.nanosecond()
}
/// Associated this `NaiveDateTime` with a [`TimeZone`], turning it into a [`DateTime`].
///
/// Note that not all datetimes may be valid in the target timezone, or a datetime may be
/// ambiguous. Use the methods on [`LocalResult`] to handle such cases.
///
/// # Example
///
/// ```
/// use chrono::{Local, NaiveDate};
///
/// let d = NaiveDate::from_ymd_opt(2016, 7, 8).unwrap().and_hms_opt(3, 5, 7).unwrap();
/// let timezone = Local;
/// let d_local = d.with_timezone(&timezone).latest().unwrap();
///
/// assert_eq!(d_local.naive_local(), d)
/// ```
#[inline]
#[must_use]
pub fn with_timezone<Tz: TimeZone>(&self, tz: &Tz) -> LocalResult<DateTime<Tz>> {
tz.from_local_datetime(self)
}
/// Adds given `Duration` to the current date and time.
///
/// As a part of Chrono's [leap second handling](./struct.NaiveTime.html#leap-second-handling),