A *date form* represents a date and possibly an associated time.
Simple date arithmetic is supported: Adding a number to a date
produces a new date shifted by that many days; adding an HMS form to
a date shifts it by that many hours. Subtracting two date forms
computes the number of days between them (represented as a simple
number). Many other operations, such as multiplying two date forms,
are nonsensical and are not allowed by Calc.

Date forms are entered and displayed enclosed in ‘`< >`’ brackets.
The default format is, e.g., ‘`<Wed Jan 9, 1991>`’ for dates,
or ‘`<3:32:20pm Wed Jan 9, 1991>`’ for dates with times.
Input is flexible; date forms can be entered in any of the usual
notations for dates and times. See Date Formats.

Date forms are stored internally as numbers, specifically the number
of days since midnight on the morning of December 31 of the year 1 BC.
If the internal number is an integer, the form represents a date only;
if the internal number is a fraction or float, the form represents
a date and time. For example, ‘`<6:00am Thu Jan 10, 1991>`’
is represented by the number 726842.25. The standard precision of
12 decimal digits is enough to ensure that a (reasonable) date and
time can be stored without roundoff error.

If the current precision is greater than 12, date forms will keep additional digits in the seconds position. For example, if the precision is 15, the seconds will keep three digits after the decimal point. Decreasing the precision below 12 may cause the time part of a date form to become inaccurate. This can also happen if astronomically high years are used, though this will not be an issue in everyday (or even everymillennium) use. Note that date forms without times are stored as exact integers, so roundoff is never an issue for them.

You can use the `v p` (`calc-pack`

) and `v u`
(`calc-unpack`

) commands to get at the numerical representation
of a date form. See Packing and Unpacking.

Date forms can go arbitrarily far into the future or past. Negative
year numbers represent years BC. There is no “year 0”; the day
before ‘`<Mon Jan 1, +1>`’ is ‘`<Sun Dec 31, -1>`’. These are
days 1 and 0 respectively in Calc’s internal numbering scheme. The
Gregorian calendar is used for all dates, including dates before the
Gregorian calendar was invented (although that can be configured; see
below). Thus Calc’s use of the day number *-10000* to
represent August 15, 28 BC should be taken with a grain of salt.

Some historical background: The Julian calendar was created by Julius Caesar in the year 46 BC as an attempt to fix the confusion caused by the irregular Roman calendar that was used before that time. The Julian calendar introduced an extra day in all years divisible by four. After some initial confusion, the calendar was adopted around the year we call 8 AD. Some centuries later it became apparent that the Julian year of 365.25 days was itself not quite right. In 1582 Pope Gregory XIII introduced the Gregorian calendar, which added the new rule that years divisible by 100, but not by 400, were not to be considered leap years despite being divisible by four. Many countries delayed adoption of the Gregorian calendar because of religious differences. For example, Great Britain and the British colonies switched to the Gregorian calendar in September 1752, when the Julian calendar was eleven days behind the Gregorian calendar. That year in Britain, the day after September 2 was September 14. To take another example, Russia did not adopt the Gregorian calendar until 1918, and that year in Russia the day after January 31 was February 14. Calc’s reckoning therefore matches English practice starting in 1752 and Russian practice starting in 1918, but disagrees with earlier dates in both countries.

When the Julian calendar was introduced, it had January 1 as the first day of the year. By the Middle Ages, many European countries had changed the beginning of a new year to a different date, often to a religious festival. Almost all countries reverted to using January 1 as the beginning of the year by the time they adopted the Gregorian calendar.

Some calendars attempt to mimic the historical situation by using the
Gregorian calendar for recent dates and the Julian calendar for older
dates. The `cal`

program in most Unix implementations does this,
for example. While January 1 wasn’t always the beginning of a calendar
year, these hybrid calendars still use January 1 as the beginning of
the year even for older dates. The customizable variable
`calc-gregorian-switch`

(see Customizing Calc) can be set to
have Calc’s date forms switch from the Julian to Gregorian calendar at
any specified date.

Today’s timekeepers introduce an occasional “leap second”.
These do not occur regularly and Calc does not take these minor
effects into account. (If it did, it would have to report a
non-integer number of days between, say,
‘`<12:00am Mon Jan 1, 1900>`’ and
‘`<12:00am Sat Jan 1, 2000>`’.)

Another day counting system in common use is, confusingly, also called
“Julian.” Julian days go from noon to noon. The Julian day number
is the numbers of days since 12:00 noon (GMT) on November 24, 4714 BC
in the Gregorian calendar (i.e., January 1, 4713 BC in the Julian
calendar). In Calc’s scheme (in GMT) the Julian day origin is
*-1721424.5*, because Calc starts at midnight instead of noon.
Thus to convert a Calc date code obtained by unpacking a
date form into a Julian day number, simply add 1721424.5 after
compensating for the time zone difference. The built-in `t J`
command performs this conversion for you.

The Julian day number is based on the Julian cycle, which was invented in 1583 by Joseph Justus Scaliger. Scaliger named it the Julian cycle since it involves the Julian calendar, but some have suggested that Scaliger named it in honor of his father, Julius Caesar Scaliger. The Julian cycle is based on three other cycles: the indiction cycle, the Metonic cycle, and the solar cycle. The indiction cycle is a 15 year cycle originally used by the Romans for tax purposes but later used to date medieval documents. The Metonic cycle is a 19 year cycle; 19 years is close to being a common multiple of a solar year and a lunar month, and so every 19 years the phases of the moon will occur on the same days of the year. The solar cycle is a 28 year cycle; the Julian calendar repeats itself every 28 years. The smallest time period which contains multiples of all three cycles is the least common multiple of 15 years, 19 years and 28 years, which (since they’re pairwise relatively prime) is 15*19*28 = 7980 years. This is the length of a Julian cycle. Working backwards, the previous year in which all three cycles began was 4713 BC, and so Scaliger chose that year as the beginning of a Julian cycle. Since at the time there were no historical records from before 4713 BC, using this year as a starting point had the advantage of avoiding negative year numbers. In 1849, the astronomer John Herschel (son of William Herschel) suggested using the number of days since the beginning of the Julian cycle as an astronomical dating system; this idea was taken up by other astronomers. (At the time, noon was the start of the astronomical day. Herschel originally suggested counting the days since Jan 1, 4713 BC at noon Alexandria time; this was later amended to noon GMT.) Julian day numbering is largely used in astronomy.

The Unix operating system measures time as an integer number of
seconds since midnight, Jan 1, 1970. To convert a Calc date
value into a Unix time stamp, first subtract 719163 (the code
for ‘`<Jan 1, 1970>`’), then multiply by 86400 (the number of
seconds in a day) and press `R` to round to the nearest
integer. If you have a date form, you can simply subtract the
day ‘`<Jan 1, 1970>`’ instead of unpacking and subtracting
719163. Likewise, divide by 86400 and add ‘`<Jan 1, 1970>`’
to convert from Unix time to a Calc date form. (Note that
Unix normally maintains the time in the GMT time zone; you may
need to subtract five hours to get New York time, or eight hours
for California time. The same is usually true of Julian day
counts.) The built-in `t U` command performs these
conversions.