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 day input.
Gets the weekday input.
Gets information on the position of the day within the year.
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.");
type Err = DateTimeError
type Err = DateTimeError
The associated error which can be returned from parsing.
Auto Trait Implementations
impl RefUnwindSafe for MockZonedDateTime
impl Send for MockZonedDateTime
impl Sync for MockZonedDateTime
impl Unpin for MockZonedDateTime
impl UnwindSafe for MockZonedDateTime
Blanket Implementations
Mutably borrows from an owned value. Read more
Clone this trait object reference, returning a boxed trait object.