Returns a normalized version of a DateTime and a time that expands to the normalized date.
impl Zone {
fn compact(&self, date: DateTime) -> (DateTime, Time)
}| Name | Description |
|---|---|
| date | The date to compact. |
This function looks at the following fields: year, month, day, hour, minute, second. All other fields will be calculated from these fields. Note that, if the date cannot be represented as a time in the given timezone (e.g. because the year is too large or the time falls into the one hour hole between winter and summer time) then the return value will not agree with the given date in the fields mentioned above but the property that the returned time expands to the returned DateTime still holds.
The fields mentioned above are normalized according to the following algorithm:
second is reduced so that it is in the [0, 60) range and minute is adjusted accordingly (this means that times that coincide with leap seconds will not be normalized correctly.)
minute is reduced so that it is in the [0, 60) range and hour is adjusted accordingly.
hour is reduced so that it is in the [0, 24) range and day is adjusted accordingly.
month is reduced so that it is in the [0, 12) range and year is adjusted accordingly.
day, month, and year are adjusted until day is a valid day in the month.