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

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

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

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

Trait Implementations

Gets the era and year input.

Gets the month input.

Gets the day input.

Gets the weekday input.

Gets information on the position of the day within the year.

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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.");

The associated error which can be returned from parsing.

Gets the hour input.

Gets the minute input.

Gets the second input.

Gets the fractional second input.

The GMT offset in Nanoseconds.

The IANA time-zone identifier. TODO(#606) switch this to BCP-47 identifier. Read more

The metazone identifier. TODO(#528) switch to a compact, stable ID. Read more

The time variant (e.g. “daylight”, “standard”) TODO(#619) use TinyStr for time variants. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Clone this trait object reference, returning a boxed trait object.

Return this boxed trait object as Box<dyn Any>. Read more

Return this trait object reference as &dyn Any. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.