gregorian
An implementation of the proleptic Gregorian calendar, compatible with ISO 8601. Amongst others, that means that the calendar has a year zero preceeding the year 1.
This create does not deal with times or time zones.
The Date
type represents a date (year, month and day),
the Year
type represents a calendar year,
the Month
type represents a calendar month,
and the YearMonth
type represents a month of a specific year.
Where possible, things are implemented as const fn
.
Currently, this excludes trait implementations and functions that rely on traits.
Example
use ;
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;
Rounding invalid dates
When you use Date::add_years()
or Date::add_months()
, you can get invalid dates.
These are reported with an InvalidDayOfMonth
error which has the
next_valid()
and prev_valid()
methods.
Those can be used to get the next or previous valid date instead.
Additionally, there is an extension trait for Result<Date, InvalidDayOfMonth>
with the
or_next_valid()
and or_prev_valid()
methods.
This allows you to directly round the date on the Result
object.
use ;
let date = new.unwrap;
assert!;
assert!;