#[non_exhaustive]pub enum MissingFieldsStrategy {
Reject,
Ecma,
}Expand description
How to infer missing fields when the fields that are present do not fully constitute a Date.
In order for the fields to fully constitute a Date, they must identify a year, a month,
and a day. The fields era, era_year, and extended_year identify the year:
| Era? | Era Year? | Extended Year? | Outcome |
|---|---|---|---|
| - | - | - | Error |
| Some | - | - | Error |
| - | Some | - | Error |
| - | - | Some | OK |
| Some | Some | - | OK |
| Some | - | Some | Error (era requires era year) |
| - | Some | Some | Error (era year requires era) |
| Some | Some | Some | OK (but error if inconsistent) |
The fields month_code and ordinal_month identify the month:
| Month Code? | Ordinal Month? | Outcome |
|---|---|---|
| - | - | Error |
| Some | - | OK |
| - | Some | OK |
| Some | Some | OK (but error if inconsistent) |
The field day identifies the day.
If the fields identify a year, a month, and a day, then there are no missing fields, so the strategy chosen here has no effect (fields that are out-of-bounds or inconsistent are handled by other errors).
Graduation tracking issue: issue #7161.
โจ Enabled with the unstable Cargo feature.
Variants (Non-exhaustive)ยง
This enum is marked as non-exhaustive
Reject
If the fields that are present do not fully constitute a Date,
return DateFromFieldsError::NotEnoughFields.
Ecma
If the fields that are present do not fully constitute a Date, follow the ECMAScript specification when possible.
โ ๏ธ This option causes a year or day to be implicitly added to the Date!
This strategy makes the following changes:
- If the fields identify a year and a month, but not a day, then set
dayto 1. - If
month_codeanddayare set but nothing else, then set the year to a reference year: some year in the calendar that contains the specified month and day, according to the ECMAScript specification.
Note that the reference year is not added if an ordinal month is present, since the identity of an ordinal month changes from year to year.
Trait Implementationsยง
Sourceยงimpl Clone for MissingFieldsStrategy
impl Clone for MissingFieldsStrategy
Sourceยงfn clone(&self) -> MissingFieldsStrategy
fn clone(&self) -> MissingFieldsStrategy
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSourceยงimpl Debug for MissingFieldsStrategy
impl Debug for MissingFieldsStrategy
Sourceยงimpl Default for MissingFieldsStrategy
impl Default for MissingFieldsStrategy
Sourceยงfn default() -> MissingFieldsStrategy
fn default() -> MissingFieldsStrategy
Sourceยงimpl PartialEq for MissingFieldsStrategy
impl PartialEq for MissingFieldsStrategy
Sourceยงfn eq(&self, other: &MissingFieldsStrategy) -> bool
fn eq(&self, other: &MissingFieldsStrategy) -> bool
self and other values to be equal, and is used by ==.