Struct icu_datetime::mock::time_zone::MockTimeZone [−][src]
pub struct MockTimeZone { pub gmt_offset: GmtOffset, pub time_zone_id: Option<String>, pub metazone_id: Option<String>, pub time_variant: Option<String>, }
A temporary struct that implements TimeZoneInput
and is used in tests, benchmarks and examples of this component.
Notice: Rust at the moment does not have a canonical way to represent time zones. We are introducing
MockTimeZone
as an example of the data necessary for ICU TimeZoneFormat
to work, and
we hope to work with the community
to develop core date and time APIs that will work as an input for this component.
Examples
use icu::datetime::mock::time_zone::MockTimeZone; use icu::datetime::date::GmtOffset; let tz1 = MockTimeZone::new( GmtOffset::default(), /* time_zone_id */ None, /* metazone_id */ None, /* time_variaint */ None, ); let tz2: MockTimeZone = "+05:00".parse() .expect("Failed to parse a time zone.");
Fields
gmt_offset: GmtOffset
The GMT offset in seconds.
time_zone_id: Option<String>
The IANA time-zone identifier
metazone_id: Option<String>
The CLDR metazone identifier
time_variant: Option<String>
The time variant e.g. “daylight” or “standard”
Implementations
impl MockTimeZone
[src]
impl MockTimeZone
[src]pub const fn new(
gmt_offset: GmtOffset,
time_zone_id: Option<String>,
metazone_id: Option<String>,
time_variant: Option<String>
) -> Self
[src]
gmt_offset: GmtOffset,
time_zone_id: Option<String>,
metazone_id: Option<String>,
time_variant: Option<String>
) -> Self
Creates a new MockTimeZone
.
A GMT offset is required, as it is used as a final fallback for formatting.
The other arguments optionally allow access to more robust formats.
Trait Implementations
impl Default for MockTimeZone
[src]
impl Default for MockTimeZone
[src]fn default() -> MockTimeZone
[src]
impl FromStr for MockTimeZone
[src]
impl FromStr for MockTimeZone
[src]type Err = DateTimeError
The associated error which can be returned from parsing.
fn from_str(input: &str) -> Result<Self, Self::Err>
[src]
Parse a MockTimeZone
from a string.
This utility is for easily creating time zones, not a complete robust solution.
The offset must range from GMT-12 to GMT+14. The string must be an ISO-8601 time zone designator: e.g. Z e.g. +05 e.g. +0500 e.g. +05:00
Examples
use icu::datetime::mock::time_zone::MockTimeZone; let tz0: MockTimeZone = "Z".parse().expect("Failed to parse a time zone."); let tz1: MockTimeZone = "+02".parse().expect("Failed to parse a time zone."); let tz2: MockTimeZone = "-0230".parse().expect("Failed to parse a time zone."); let tz3: MockTimeZone = "+02:30".parse().expect("Failed to parse a time zone.");
impl TimeZoneInput for MockTimeZone
[src]
impl TimeZoneInput for MockTimeZone
[src]fn gmt_offset(&self) -> GmtOffset
[src]
fn time_zone_id(&self) -> Option<&str>
[src]
fn metazone_id(&self) -> Option<&str>
[src]
fn time_variant(&self) -> Option<&str>
[src]
Auto Trait Implementations
impl RefUnwindSafe for MockTimeZone
impl RefUnwindSafe for MockTimeZone
impl Send for MockTimeZone
impl Send for MockTimeZone
impl Sync for MockTimeZone
impl Sync for MockTimeZone
impl Unpin for MockTimeZone
impl Unpin for MockTimeZone
impl UnwindSafe for MockTimeZone
impl UnwindSafe for MockTimeZone