Struct icu_datetime::mock::zoned_datetime::MockZonedDateTime[][src]

pub struct MockZonedDateTime {
    pub datetime: MockDateTime,
    pub time_zone: MockTimeZone,
}

A temporary struct that implements ZonedDateTimeInput and is used in tests, benchmarks and examples of this component.

The composition of MockDateTime and MockTimeZone.

Notice: Rust at the moment does not have a canonical way to represent date and time. We are introducing MockZonedDateTime as an example of the data necessary for ICU ZonedDateTimeFormat 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::datetime::MockDateTime;
use icu::datetime::mock::time_zone::MockTimeZone;
use icu::datetime::mock::zoned_datetime::MockZonedDateTime;

let dt: MockDateTime = "2020-10-14T13:21:00".parse()
    .expect("Failed to parse a datetime.");

let tz: MockTimeZone = "+05:00".parse()
    .expect("Failed to parse a time zone.");

let zdt1 = MockZonedDateTime::new(dt, tz);
let zdt2: MockZonedDateTime = "2020-10-14T13:21:00+05:00".parse()
    .expect("Failed to parse a zoned datetime.");

Fields

datetime: MockDateTime

The datetime component.

time_zone: MockTimeZone

The time zone component.

Implementations

impl MockZonedDateTime[src]

pub const fn new(datetime: MockDateTime, time_zone: MockTimeZone) -> Self[src]

Creates a new MockZonedDateTime from an already validated MockDateTime and MockTimeZone.

Trait Implementations

impl DateInput for MockZonedDateTime[src]

impl Debug for MockZonedDateTime[src]

impl Default for MockZonedDateTime[src]

impl FromStr for MockZonedDateTime[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 MockZonedDateTime from a string.

This utility is for easily creating dates, not a complete robust solution. The string must take a specific form of the ISO 8601 format: YYYY-MM-DDThh:mm:ssZ, YYYY-MM-DDThh:mm:ss±hh, YYYY-MM-DDThh:mm:ss±hhmm, YYYY-MM-DDThh:mm:ss±hh:mm,

Examples

use icu::datetime::mock::zoned_datetime::MockZonedDateTime;

let date: MockZonedDateTime = "2020-10-14T13:21:00+05:30".parse()
    .expect("Failed to parse a zoned datetime.");

impl IsoTimeInput for MockZonedDateTime[src]

impl TimeZoneInput for MockZonedDateTime[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> DateTimeInput for T where
    T: DateInput + IsoTimeInput
[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.

impl<T> ZonedDateTimeInput for T where
    T: TimeZoneInput + DateTimeInput
[src]