Skip to content

Commit

Permalink
Remove remaining chrono code. (#682)
Browse files Browse the repository at this point in the history
In 9721646, the `with-chrono`
feature was removed, but this dead code lingered.
  • Loading branch information
waywardmonkeys authored May 27, 2024
1 parent c2cca87 commit 6940925
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions core-foundation/src/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ use crate::base::TCFType;
use crate::date::{CFDate, CFTimeInterval};
use crate::string::CFString;

#[cfg(feature = "with-chrono")]
use chrono::{FixedOffset, NaiveDateTime};

declare_TCFType! {
/// A time zone.
CFTimeZone, CFTimeZoneRef
Expand Down Expand Up @@ -56,17 +53,6 @@ impl CFTimeZone {
unsafe { CFTimeZoneGetSecondsFromGMT(self.0, date.abs_time()) }
}

#[cfg(feature = "with-chrono")]
pub fn offset_at_date(&self, date: NaiveDateTime) -> FixedOffset {
let date = CFDate::from_naive_utc(date);
FixedOffset::east(self.seconds_from_gmt(date) as i32)
}

#[cfg(feature = "with-chrono")]
pub fn from_offset(offset: FixedOffset) -> CFTimeZone {
CFTimeZone::new(offset.local_minus_utc() as f64)
}

/// The timezone database ID that identifies the time zone. E.g. `"America/Los_Angeles" `or
/// `"Europe/Paris"`.
pub fn name(&self) -> CFString {
Expand All @@ -78,22 +64,10 @@ impl CFTimeZone {
mod test {
use super::CFTimeZone;

#[cfg(feature = "with-chrono")]
use chrono::{FixedOffset, NaiveDateTime};

#[test]
fn timezone_comparison() {
let system = CFTimeZone::system();
let default = CFTimeZone::default();
assert_eq!(system, default);
}

#[test]
#[cfg(feature = "with-chrono")]
fn timezone_chrono_conversion() {
let offset = FixedOffset::west(28800);
let tz = CFTimeZone::from_offset(offset);
let converted = tz.offset_at_date(NaiveDateTime::from_timestamp(0, 0));
assert_eq!(offset, converted);
}
}

0 comments on commit 6940925

Please sign in to comment.