2 B.6. History of Units #
4 The SQL standard states that “Within the definition of a ‘datetime
5 literal’, the ‘datetime values’ are constrained by the natural rules
6 for dates and times according to the Gregorian calendar”. PostgreSQL
7 follows the SQL standard's lead by counting dates exclusively in the
8 Gregorian calendar, even for years before that calendar was in use.
9 This rule is known as the proleptic Gregorian calendar.
11 The Julian calendar was introduced by Julius Caesar in 45 BC. It was in
12 common use in the Western world until the year 1582, when countries
13 started changing to the Gregorian calendar. In the Julian calendar, the
14 tropical year is approximated as 365 1/4 days = 365.25 days. This gives
15 an error of about 1 day in 128 years.
17 The accumulating calendar error prompted Pope Gregory XIII to reform
18 the calendar in accordance with instructions from the Council of Trent.
19 In the Gregorian calendar, the tropical year is approximated as 365 +
20 97 / 400 days = 365.2425 days. Thus it takes approximately 3300 years
21 for the tropical year to shift one day with respect to the Gregorian
24 The approximation 365+97/400 is achieved by having 97 leap years every
25 400 years, using the following rules:
26 Every year divisible by 4 is a leap year.
27 However, every year divisible by 100 is not a leap year.
28 However, every year divisible by 400 is a leap year after all.
30 So, 1700, 1800, 1900, 2100, and 2200 are not leap years. But 1600,
31 2000, and 2400 are leap years. By contrast, in the older Julian
32 calendar all years divisible by 4 are leap years.
34 The papal bull of February 1582 decreed that 10 days should be dropped
35 from October 1582 so that 15 October should follow immediately after 4
36 October. This was observed in Italy, Poland, Portugal, and Spain. Other
37 Catholic countries followed shortly after, but Protestant countries
38 were reluctant to change, and the Greek Orthodox countries didn't
39 change until the start of the 20th century. The reform was observed by
40 Great Britain and its dominions (including what is now the USA) in
41 1752. Thus 2 September 1752 was followed by 14 September 1752. This is
42 why Unix systems that have the cal program produce the following:
50 But, of course, this calendar is only valid for Great Britain and
51 dominions, not other places. Since it would be difficult and confusing
52 to try to track the actual calendars that were in use in various places
53 at various times, PostgreSQL does not try, but rather follows the
54 Gregorian calendar rules for all dates, even though this method is not
55 historically accurate.
57 Different calendars have been developed in various parts of the world,
58 many predating the Gregorian system. For example, the beginnings of the
59 Chinese calendar can be traced back to the 14th century BC. Legend has
60 it that the Emperor Huangdi invented that calendar in 2637 BC. The
61 People's Republic of China uses the Gregorian calendar for civil
62 purposes. The Chinese calendar is used for determining festivals.