pub struct MockZonedDateTime {
    pub datetime: DateTime<Gregorian>,
    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 DateTime<Gregorian> 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::parse_gregorian_from_str;
use icu::datetime::mock::time_zone::MockTimeZone;
use icu::calendar::{DateTime, Gregorian};
use icu::datetime::mock::zoned_datetime::MockZonedDateTime;

let dt: DateTime<Gregorian> = parse_gregorian_from_str("2020-10-14T13:21:00")
    .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: DateTime<Gregorian>

The datetime component.

time_zone: MockTimeZone

The time zone component.

Implementations

Creates a new MockZonedDateTime from an already validated DateTime<Gregorian> and MockTimeZone.

Trait Implementations

The CLDR calendar this date relates to

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

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 nanosecond input.

The GMT offset in Nanoseconds.

The IANA time-zone identifier.

The metazone identifier.

The time variant (e.g. “daylight”, “standard”)

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.