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]

pub const fn new(
    gmt_offset: GmtOffset,
    time_zone_id: Option<String>,
    metazone_id: Option<String>,
    time_variant: Option<String>
) -> MockTimeZone
[src]

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 Debug for MockTimeZone[src]

impl Default for MockTimeZone[src]

impl FromStr for MockTimeZone[src]

type Err = DateTimeError

The associated error which can be returned from parsing.

pub fn from_str(
    input: &str
) -> Result<MockTimeZone, <MockTimeZone as FromStr>::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]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.