Struct icu_datetime::mock::datetime::MockDateTime[][src]

pub struct MockDateTime {
    pub year: i32,
    pub month: u32,
    pub day: u32,
    pub hour: IsoHour,
    pub minute: IsoMinute,
    pub second: IsoSecond,
}
Expand description

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

All fields in MockDateTime are 0-based. For example, January is represented as 0, not 1.

Notice: Rust at the moment does not have a canonical way to represent date and time. We are introducing MockDateTime as an example of the data necessary for ICU DateTimeFormat 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;

let dt1 = MockDateTime::try_new(2020, 9, 24, 13, 21, 0)
    .expect("Failed to construct DateTime.");

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

Fields

year: i32

ISO-8601 year (proleptic Gregorian).

month: u32

0-based month index.

day: u32

0-based day index.

hour: IsoHour

0-based hour.

minute: IsoMinute

0-based minute.

second: IsoSecond

0-based second.

Implementations

Creates a new MockDateTime from a list of already validated date/time parameters.

Constructor for MockDateTime.

Examples

use icu::datetime::mock::datetime::MockDateTime;

let dt = MockDateTime::try_new(2020, 9, 24, 13, 21, 0)
    .expect("Failed to construct a DateTime");

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 MockDateTime 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:ss.

use icu::datetime::mock::datetime::MockDateTime;

let date: MockDateTime = "2020-10-14T13:21:00".parse()
    .expect("Failed to parse a 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.

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.