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