Time.Calendar
Day numbers of the proleptic Gregorian calendar: the conversion between a
(year, month, day) and the count of days since 1970-01-01, which is how
Date is stored. Everything here is total arithmetic; validating a date is
the caller's job.
The conversions are Howard Hinnant's days_from_civil and civil_from_days.
They shift the year to start on March 1, so that the leap day is the last
day of its year and the month lengths from March on follow the line
(153 * m + 2) / 5, then count in 400-year eras of exactly 146,097 days.
Each era is handled with non-negative numbers only, which is why every
division of a value that can be negative goes through floorDiv: / rounds
toward zero, and would put day -1 in the wrong era.
A day of the calendar a wall clock is read against, by its number. Unlike a
Date it has no range: a time zone rule is worked out for the year either
side of the dates there are.
The day n days after 1970-01-01, and back: for Date's public
fromEpochDays and epochDays, and for Frame, which counts seconds from
the same midnight. Everything else moves between days with the functions
below.
The number of days from from to to: negative if to is earlier.
The first w on or after d.
The years a Date may have: four digits either side of year 0, the range
ISO 8601 writes without an agreed expansion.
Rounds toward negative infinity, unlike /. Written so that no step
overflows, since instants use it on the whole range of Int.
The day number of a valid date.
The date of a day number, as (year, month, day).