Module:Date/doc

This module provides date functions for use by other modules. Dates in the Gregorian calendar and the Julian calendar are supported, from 9999 BCE to 9999 CE. The calendars are proleptic—they are assumed to apply at all times with no irregularities.

A date, with an optional time, can be specified in a variety of formats, and can be converted for display using a variety of formats, for example, 1 April 2016 or April 1, 2016. The properties of a date include its Julian date and its Gregorian serial date, as well as the day-of-week and day-of-year.

Dates can be compared (for example, ), and can be used with add or subtract (for example,  ). The difference between two dates can be determined with. These operations work with both Gregorian and Julian calendar dates, but  is nil if the two dates use different calendars.

The module provides the following items.

Formatted output
A date can be formatted as text.

The following simplified formatting codes are available.

The following formatting codes (similar to strftime) are available.

In addition,  (where   is any property of a date) can be used.

For example,  has the following properties.

Some shortcuts are available. Given, the following results would occur.

Julian date
The following has an example of converting a Julian date to a date, then obtaining information about the date.

Date differences
The difference between two dates can be determined with. The result is valid if both dates use the Gregorian calendar or if both dates use the Julian calendar, otherwise the result is nil. An age and duration can be calculated from a date difference.

For example:

A date difference holds the original dates except they are swapped so  (  is the more recent date). This is shown in the following.

A date difference also holds a time difference:

A date difference can be added to a date, or subtracted from a date.

The age and duration methods of a date difference accept a code that identifies the components that should be returned. An extra day is included for the duration method because it includes the final day.