Module chrono::naive::date [] [src]

ISO 8601 calendar date without timezone.

Calendar Date

The ISO 8601 calendar date follows the proleptic Gregorian calendar. It is like a normal civil calendar but note some slight differences:

  • Dates before the Gregorian calendar's inception in 1582 are defined via the extrapolation. Be careful, as historical dates are often noted in the Julian calendar and others and the transition to Gregorian may differ across countries (as late as early 20C).

    (Some example: Both Shakespeare from Britain and Cervantes from Spain seemingly died on the same calendar date---April 23, 1616---but in the different calendar. Britain used the Julian calendar at that time, so Shakespeare's death is later.)

  • ISO 8601 calendars has the year 0, which is 1 BCE (a year before 1 CE). If you need a typical BCE/BC and CE/AD notation for year numbers, use the Datelike::year_ce method.

Week Date

The ISO 8601 week date is a triple of year number, week number and day of the week with the following rules:

  • A week consists of Monday through Sunday, and is always numbered within some year. The week number ranges from 1 to 52 or 53 depending on the year.

  • The week 1 of given year is defined as the first week containing January 4 of that year, or equivalently, the first week containing four or more days in that year.

  • The year number in the week date may not correspond to the actual Gregorian year. For example, January 3, 2016 (Sunday) was on the last (53rd) week of 2015.

Chrono's date types default to the ISO 8601 calendar date, but the Datelike::isoweekdate method can be used to get the corresponding week date.

Ordinal Date

The ISO 8601 ordinal date is a pair of year number and day of the year ("ordinal"). The ordinal number ranges from 1 to 365 or 366 depending on the year. The year number is same to that of the calendar date.

This is currently the internal format of Chrono's date types.

Structs

NaiveDate

ISO 8601 calendar date without timezone. Allows for every proleptic Gregorian date from Jan 1, 262145 BCE to Dec 31, 262143 CE. Also supports the conversion from ISO 8601 ordinal and week date.

Constants

MAX

The maximum possible NaiveDate (December 31, 262143 CE).

MIN

The minimum possible NaiveDate (January 1, 262145 BCE).