Skip to content

Commit

Permalink
use explicity created timezone instead of adding PartialEq and Eq to …
Browse files Browse the repository at this point in the history
…the Local struct
  • Loading branch information
Kurtis Nusbaum committed Feb 25, 2023
1 parent 4d7764d commit 3463010
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/naive/datetime/mod.rs
Expand Up @@ -897,9 +897,11 @@ impl NaiveDateTime {
/// # Example
///
/// ```
/// use chrono::{NaiveDate, Local};
/// let dt = NaiveDate::from_ymd_opt(2015, 9, 5).unwrap().and_hms_opt(23, 56, 4).unwrap().and_local_timezone(Local).unwrap();
/// assert_eq!(dt.timezone(), Local);
/// use chrono::{NaiveDate, FixedOffset};
/// let hour = 3600;
/// let tz = FixedOffset::east_opt(5 * hour).unwrap();
/// let dt = NaiveDate::from_ymd_opt(2015, 9, 5).unwrap().and_hms_opt(23, 56, 4).unwrap().and_local_timezone(tz).unwrap();
/// assert_eq!(dt.timezone(), tz);
pub fn and_local_timezone<Tz: TimeZone>(&self, tz: Tz) -> LocalResult<DateTime<Tz>> {
tz.from_local_datetime(self)
}
Expand Down
2 changes: 1 addition & 1 deletion src/offset/local/mod.rs
Expand Up @@ -51,7 +51,7 @@ mod tz_info;
/// let dt: DateTime<Local> = Local::now();
/// let dt: DateTime<Local> = Local.timestamp(0, 0);
/// ```
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "rkyv", derive(Archive, Deserialize, Serialize))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Local;
Expand Down

0 comments on commit 3463010

Please sign in to comment.