Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core-foundation-sys/src/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::os::raw::c_void;

use base::{CFAllocatorRef, CFTypeID};
use date::{CFTimeInterval, CFAbsoluteTime};
use string::CFStringRef;

#[repr(C)]
pub struct __CFTimeZone(c_void);
Expand All @@ -24,4 +25,5 @@ extern {
pub fn CFTimeZoneGetSecondsFromGMT(tz: CFTimeZoneRef, time: CFAbsoluteTime) -> CFTimeInterval;

pub fn CFTimeZoneGetTypeID() -> CFTypeID;
pub fn CFTimeZoneGetName(tz: CFTimeZoneRef) -> CFStringRef;
}
9 changes: 9 additions & 0 deletions core-foundation/src/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use core_foundation_sys::base::kCFAllocatorDefault;

use base::TCFType;
use date::{CFDate, CFTimeInterval};
use string::CFString;

#[cfg(feature = "with-chrono")]
use chrono::{FixedOffset, NaiveDateTime};
Expand Down Expand Up @@ -68,6 +69,14 @@ impl CFTimeZone {
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 {
unsafe {
CFString::wrap_under_get_rule(CFTimeZoneGetName(self.0))
}
}
}

#[cfg(test)]
Expand Down