rev |
line source |
yuuji@0
|
1 /* ========================================================================
|
yuuji@0
|
2 * Copyright 1988-2006 University of Washington
|
yuuji@0
|
3 *
|
yuuji@0
|
4 * Licensed under the Apache License, Version 2.0 (the "License");
|
yuuji@0
|
5 * you may not use this file except in compliance with the License.
|
yuuji@0
|
6 * You may obtain a copy of the License at
|
yuuji@0
|
7 *
|
yuuji@0
|
8 * http://www.apache.org/licenses/LICENSE-2.0
|
yuuji@0
|
9 *
|
yuuji@0
|
10 *
|
yuuji@0
|
11 * ========================================================================
|
yuuji@0
|
12 */
|
yuuji@0
|
13
|
yuuji@0
|
14 ALL ABOUT CALENDARS
|
yuuji@0
|
15
|
yuuji@0
|
16 Although one can never be sure of what will happen at some future
|
yuuji@0
|
17 time, there is strong historical precedent for presuming that the
|
yuuji@0
|
18 present Gregorian calendar will still be in effect within the useful
|
yuuji@0
|
19 lifetime of the IMAP toolkit. We have therefore chosen to adhere to
|
yuuji@0
|
20 these precedents.
|
yuuji@0
|
21
|
yuuji@0
|
22 The purpose of a calendar is to reckon time in advance, to show
|
yuuji@0
|
23 how many days have to elapse until a certain event takes place in the
|
yuuji@0
|
24 future, such as the harvest or the release of a new version of Pine.
|
yuuji@0
|
25 The earliest calendars, naturally, were crude and tended to be based
|
yuuji@0
|
26 upon the seasons or the lunar cycle.
|
yuuji@0
|
27
|
yuuji@0
|
28
|
yuuji@0
|
29 ANCIENT CALENDARS
|
yuuji@0
|
30
|
yuuji@0
|
31 The calendar of the Assyrians, for example, was based upon the
|
yuuji@0
|
32 phases of the moon. They knew that a lunation (the time from one full
|
yuuji@0
|
33 moon to the next) was 29 1/2 days long, so their lunar year had a
|
yuuji@0
|
34 duration of 354 days. This fell short of the solar year by about 11
|
yuuji@0
|
35 days. (The exact time for the solar year is approximately 365 days, 5
|
yuuji@0
|
36 hours, 48 minutes, and 46 seconds.) After 3 years, such a lunar
|
yuuji@0
|
37 calendar would be off by a whole month, so the Assyrians added an extra
|
yuuji@0
|
38 month from time to time to keep their calendar in synchronization with
|
yuuji@0
|
39 the seasons.
|
yuuji@0
|
40
|
yuuji@0
|
41 The best approximation that was possible in antiquity was a 19-year
|
yuuji@0
|
42 period, with 7 of these 19 years having 13 months (leap months). This
|
yuuji@0
|
43 scheme was adopted as the basis for the lunar calendar used by the
|
yuuji@0
|
44 Hebrews. The Arabs also used this calendar until Mohammed forbade
|
yuuji@0
|
45 shifting from 12 months to 13 months; this causes the Muslim holy month
|
yuuji@0
|
46 of Ramadan to move backwards through the seasons, completing a cycle
|
yuuji@0
|
47 every 32 1/2 years.
|
yuuji@0
|
48
|
yuuji@0
|
49 When Rome emerged as a world power, the difficulties of making a
|
yuuji@0
|
50 calendar were well known, but the Romans complicated their lives because
|
yuuji@0
|
51 of their superstition that even numbers were unlucky. Hence their
|
yuuji@0
|
52 months were 29 or 31 days long, with the exception of February, which
|
yuuji@0
|
53 had 28 days. Every second year, the Roman calendar included an extra
|
yuuji@0
|
54 month called Mercedonius of 22 or 23 days to keep up with the solar
|
yuuji@0
|
55 year.
|
yuuji@0
|
56
|
yuuji@0
|
57
|
yuuji@0
|
58 JULIAN CALENDAR
|
yuuji@0
|
59
|
yuuji@0
|
60 Even this algorithm was very poor, so that in 45 BCE, Caesar,
|
yuuji@0
|
61 advised by the astronomer Sosigenes, ordered a sweeping reform. By
|
yuuji@0
|
62 imperial decree, the year 46 BCE was made 445 days long to bring the
|
yuuji@0
|
63 calendar back in step with the seasons. The new calendar, similar to
|
yuuji@0
|
64 the one we now use was called the Julian calendar (named after Julius
|
yuuji@0
|
65 Caesar).
|
yuuji@0
|
66
|
yuuji@0
|
67 Months in the Julian calendar were 30 or 31 days in length and
|
yuuji@0
|
68 every fourth year was made a leap year (having 366 days) by adding a day
|
yuuji@0
|
69 to the end of the year. This leap year rule was not consistantly
|
yuuji@0
|
70 applied until 8 CE. The year-ending month of February, never a popular
|
yuuji@0
|
71 month, was presently shortened so that Julius Caesar and Emperor
|
yuuji@0
|
72 Augustus could each have long months named after them.
|
yuuji@0
|
73
|
yuuji@0
|
74 Caesar also decreed that the year would start with the first of
|
yuuji@0
|
75 January, which since 153 BCE was the day that Roman consuls took office,
|
yuuji@0
|
76 and not the vernal equinox in late March. Not everyone accepted that
|
yuuji@0
|
77 part of his reform, as we shall see.
|
yuuji@0
|
78
|
yuuji@0
|
79
|
yuuji@0
|
80 GREGORIAN CALENDAR
|
yuuji@0
|
81
|
yuuji@0
|
82 Caesar's year was 11 1/2 minutes short of the calculations
|
yuuji@0
|
83 recommended by Sosigenes and eventually the date of the vernal equinox
|
yuuji@0
|
84 began to drift. Roger Bacon became alarmed and sent a note to Pope
|
yuuji@0
|
85 Clement IV, who apparently was not impressed. Pope Sixtus IV later
|
yuuji@0
|
86 became convinced that another reform was needed and called the German
|
yuuji@0
|
87 astronomer, Regiomontanus, to Rome to advise him. Unfortunately,
|
yuuji@0
|
88 Regiomontanus died of the plague shortly thereafter and the plans died
|
yuuji@0
|
89 as well.
|
yuuji@0
|
90
|
yuuji@0
|
91 In 1545, the Council of Trent authorized Pope Gregory XIII to
|
yuuji@0
|
92 reform the calendar once more. Most of the mathematical work was done
|
yuuji@0
|
93 by Father Christopher Clavius, S.J. The immediate correction that was
|
yuuji@0
|
94 adopted was that Thursday, October 4, 1582 was to be the last day of the
|
yuuji@0
|
95 Julian calendar. The next day was Friday, with the date of October 15.
|
yuuji@0
|
96 For long range accuracy, a formula suggested by the Vatican librarian
|
yuuji@0
|
97 Aloysius Giglio was adopted. It said that every fourth year is a leap
|
yuuji@0
|
98 year except for century years that are not divisible by 400. Thus 1700,
|
yuuji@0
|
99 1800 and 1900 would not be leap years, but 2000 would be a leap year
|
yuuji@0
|
100 since 2000 is divisible by 400. This rule eliminates 3 leap years every
|
yuuji@0
|
101 4 centuries, making the calendar sufficiently correct for most ordinary
|
yuuji@0
|
102 purposes. This calendar is known as the Gregorian calendar and is the
|
yuuji@0
|
103 one that we now use today.
|
yuuji@0
|
104
|
yuuji@0
|
105 It is interesting to note that in 1582, all the Protestant princes
|
yuuji@0
|
106 ignored the papal decree and so many countries continued to use the
|
yuuji@0
|
107 Julian calendar until either 1698 or 1752. Britain and its American
|
yuuji@0
|
108 colonies went from Wednesday, September 2, 1752 to Thursday, September
|
yuuji@0
|
109 14. Prior to the changeover, the British used March 25 as the start of
|
yuuji@0
|
110 the new year.
|
yuuji@0
|
111
|
yuuji@0
|
112 In Russia, it needed the revolution to introduce the Gregorian
|
yuuji@0
|
113 calendar in 1918. Turkey didn't adopt it until 1927.
|
yuuji@0
|
114
|
yuuji@0
|
115
|
yuuji@0
|
116 NUMBERING OF YEARS
|
yuuji@0
|
117
|
yuuji@0
|
118 The numbering of the year is generally done according to an "era",
|
yuuji@0
|
119 such as the year of a ruler's reign.
|
yuuji@0
|
120
|
yuuji@0
|
121 In about 525, a monk named Dionysius Exiguus suggested that the
|
yuuji@0
|
122 calculated year of Jesus' birth be designated as year 1 in the Julian
|
yuuji@0
|
123 calendar. This suggestion was adopted over the next 500 years and
|
yuuji@0
|
124 subsequently followed in the Gregorian calendar.
|
yuuji@0
|
125
|
yuuji@0
|
126 For the benefit of those who seek religious significance to the
|
yuuji@0
|
127 calendar millenium, note that year 1 is too late by at least 4 years.
|
yuuji@0
|
128 Herod the Great, named in the Christian Bible as having all children in
|
yuuji@0
|
129 Bethlehem put to death in an attempt to kill the infant Jesus, died in 4
|
yuuji@0
|
130 BCE.
|
yuuji@0
|
131
|
yuuji@0
|
132 Nothing particularly significant of an historic or religious nature
|
yuuji@0
|
133 happened in Gregorian year 1; however it has become a worldwide standard
|
yuuji@0
|
134 as the "common era." In modern times, the terms "CE" (common era) and
|
yuuji@0
|
135 "BCE" (before common era) are preferred over the earlier (and, as we
|
yuuji@0
|
136 have seen, less accurate) "AD" (anno Domini, "the year of the Lord") and
|
yuuji@0
|
137 "BC" (before Christ).
|
yuuji@0
|
138
|
yuuji@0
|
139 The Hebrew lunar calendar begins at 3760 BCE, the year of creation
|
yuuji@0
|
140 in Jewish tradition. The Muslim lunar calendar begins on July 16, 622,
|
yuuji@0
|
141 when Mohammed fled from Mecca to Medina.
|
yuuji@0
|
142
|
yuuji@0
|
143 The Japanese, Taiwanese, and North Koreans use the Gregorian
|
yuuji@0
|
144 calendar, but number the year by political era. In Japan, an era
|
yuuji@0
|
145 begins when an emperor succeeds to the throne; year 1 of the Heisei
|
yuuji@0
|
146 era was 1989 when Emperor Akihito ascended to the throne (the first
|
yuuji@0
|
147 few days of 1989 was year 64 of the Shouwa era). In Taiwan, year 1 is
|
yuuji@0
|
148 the first full year after the founding of the Republic of China in 1911.
|
yuuji@0
|
149 In North Korea, year 1 is the year of the Juche (self-reliance) ideal,
|
yuuji@0
|
150 corresponding to the birth year of founder Kim Il-Sung (1912). Thus,
|
yuuji@0
|
151 year 2000 is Heisei 12 (Japan), 89th year of the Republic (Taiwan),
|
yuuji@0
|
152 and Juche 89 (North Korea).
|
yuuji@0
|
153
|
yuuji@0
|
154
|
yuuji@0
|
155 FURTHER MODIFICATIONS TO THE GREGORIAN CALENDAR
|
yuuji@0
|
156
|
yuuji@0
|
157 Despite the great accuracy of the Gregorian calendar, it still
|
yuuji@0
|
158 falls behind very slightly every few years. The most serious problem
|
yuuji@0
|
159 is that the earth's rotation is slowing gradually. If you are very
|
yuuji@0
|
160 concerned about this problem, we suggest that you tune in short wave
|
yuuji@0
|
161 radio station WWV or the Global Positioning System, which broadcasts
|
yuuji@0
|
162 official time signals for use in the United States. About once every
|
yuuji@0
|
163 3 years, they declare a leap second at which time you should be
|
yuuji@0
|
164 careful to adjust your system clock. If you have trouble picking up
|
yuuji@0
|
165 their signals, we suggest you purchase an atomic clock (not part of
|
yuuji@0
|
166 the IMAP toolkit).
|
yuuji@0
|
167
|
yuuji@0
|
168 Another problem is that the Gregorian calendar represents a year
|
yuuji@0
|
169 of 365.2425 days, whereas the actual time taken for the earth to
|
yuuji@0
|
170 rotate around the Sun is 365.2421991 days. Thus, the Gregorian calendar
|
yuuji@0
|
171 is actually 26 seconds slow each year, resulting in the calendar
|
yuuji@0
|
172 being one day behind every 3,300 or so years (a Y3.3K problem).
|
yuuji@0
|
173
|
yuuji@0
|
174 Consequently, the Gregorian calendar has been modified with a
|
yuuji@0
|
175 further rule, which is that years evenly divisible by 4000 are not
|
yuuji@0
|
176 leap years. Thus, the year 4000 will not be a leap year. Or, at
|
yuuji@0
|
177 least we assume that's what will happen assuming that the calendar
|
yuuji@0
|
178 remains unchanged for the next 2000 years.
|
yuuji@0
|
179
|
yuuji@0
|
180 The modified Gregorian calendar represents a year of 365.24225
|
yuuji@0
|
181 days. Thus, the modified Gregorian calendar is actually 4 seconds
|
yuuji@0
|
182 slow each year, resulting in the calendar being one day slow every
|
yuuji@0
|
183 20,000 or so years. So there will be a Y20K problem.
|
yuuji@0
|
184
|
yuuji@0
|
185 There is some dispute whether the modified Gregorian calendar was
|
yuuji@0
|
186 officially adopted, or if it's just a proposal. Other options (see
|
yuuji@0
|
187 below) exist; fortunately no decision needs to be made for several
|
yuuji@0
|
188 centuries yet.
|
yuuji@0
|
189
|
yuuji@0
|
190 There is code in c-client to support the modified Gregorian
|
yuuji@0
|
191 calendar, although it is currently disabled. Sometime in the next
|
yuuji@0
|
192 2000 years, someone will need to enable this code so that c-client is
|
yuuji@0
|
193 Y4K compiliant. Then, 18,000 years from now, someone will have to
|
yuuji@0
|
194 tear into c-client's code to fix the Y20K bug.
|
yuuji@0
|
195
|
yuuji@0
|
196
|
yuuji@0
|
197 EASTERN ORTHODOX MODIFICATION OF THE GREGORIAN CALENDAR
|
yuuji@0
|
198
|
yuuji@0
|
199 The Eastern Orthodox church in 1923 established its own rules to
|
yuuji@0
|
200 correct the Julian calendar. In their calendar, century years modulo
|
yuuji@0
|
201 900 must result in value of 200 or 600 to be considered a leap year.
|
yuuji@0
|
202 Both the Orthodox and Gregorian calendar agree that the years 2000 and
|
yuuji@0
|
203 2400 will be leap years, and the years 1900, 2100, 2200, 2300, 2500,
|
yuuji@0
|
204 2600, 2700 are not. However, the year 2800 will be a leap year in the
|
yuuji@0
|
205 Gregorian calendar but not in the Orthodox calendar; similarly, the
|
yuuji@0
|
206 year 2900 will be a leap year in the Orthodox calendar but not in the
|
yuuji@0
|
207 Gregorian calendar. Both calendars will agree that 3000 and
|
yuuji@0
|
208 3100 are leap years, but will disagree again in 3200 and 3300.
|
yuuji@0
|
209
|
yuuji@0
|
210 There is code in c-client to support the Orthodox calendar. It
|
yuuji@0
|
211 can be enabled by adding -DUSEORTHODOXCALENDAR=1 to the c-client
|
yuuji@0
|
212 CFLAGS, e.g.
|
yuuji@0
|
213 make xxx EXTRACFLAGS="-DUSEORTHODOXCALENDAR=1"
|
yuuji@0
|
214
|
yuuji@0
|
215 The Orthodox calendar represents a year of 365.24222222... days.
|
yuuji@0
|
216 Thus, the Orthodox calendar is actually 2 seconds slow each year,
|
yuuji@0
|
217 resulting in the calendar being one day slow every 40,000 or so years.
|
yuuji@0
|
218 The Eastern Orthodox church has not yet made any statements on how the
|
yuuji@0
|
219 Y40K bug will be fixed.
|
yuuji@0
|
220
|
yuuji@0
|
221
|
yuuji@0
|
222 OTHER ISSUES AFFECTING THE CALENDAR IN THE FUTURE
|
yuuji@0
|
223
|
yuuji@0
|
224 The effect of leap seconds also needs to be considered when
|
yuuji@0
|
225 looking at the Y3.3K/Y4K, Y20K, and Y40K problems. Leap seconds put
|
yuuji@0
|
226 the clock back in line with the Earth's rotation, whereas leap years
|
yuuji@0
|
227 put the calendar back in line with the Earth's revolution. Since leap
|
yuuji@0
|
228 seconds slow down the clock (and hence the calendar), they actually
|
yuuji@0
|
229 bring the day of reckoning for the Gregorian and Orthodox calendars
|
yuuji@0
|
230 sooner.
|
yuuji@0
|
231
|
yuuji@0
|
232 Another factor is that the next ice age (technically, the end of
|
yuuji@0
|
233 the current interglacial period; we are in the middle of an ice age
|
yuuji@0
|
234 now!) is due around Y25K. It is not known what perturbations this will
|
yuuji@0
|
235 cause on the Earth's rotation and revolution, nor what calendar
|
yuuji@0
|
236 adjustments will be necessary at that time.
|
yuuji@0
|
237
|
yuuji@0
|
238 Hence my use of "or so" in predicting the years that the calendar
|
yuuji@0
|
239 will fall behind. The actual point may be anywhere from decades (in the
|
yuuji@0
|
240 case of Y3.3K) to millenia (in the case of Y40K) off from these predictions.
|
yuuji@0
|
241
|
yuuji@0
|
242
|
yuuji@0
|
243 MEANINGS OF DAY NAMES
|
yuuji@0
|
244
|
yuuji@0
|
245 The names of days of the week from a combination of Roman and
|
yuuji@0
|
246 Germanic names for celestial bodies:
|
yuuji@0
|
247 . Sunday Latin "dies solis" => "Sun's day"
|
yuuji@0
|
248 . Monday Latin "dies lunae" => "Moon's day"
|
yuuji@0
|
249 . Tuesday Germanic "Tiw's day" => "Mars' day"
|
yuuji@0
|
250 . Wednesday Germanic "Woden's day" => "Mercury's day"
|
yuuji@0
|
251 . Thursday Germanic "Thor's day" => "Jupiter's day"
|
yuuji@0
|
252 . Friday Germanic "Frigg's day" => "Venus' day"
|
yuuji@0
|
253 . Saturday Latin "dies Saturni" => "Saturn's day"
|
yuuji@0
|
254
|
yuuji@0
|
255
|
yuuji@0
|
256 MEANINGS OF MONTH NAMES
|
yuuji@0
|
257
|
yuuji@0
|
258 The names of the months are from the Roman calendar:
|
yuuji@0
|
259 . January Janus, protector of doorways
|
yuuji@0
|
260 . February Februalia, a time for sacrifice to atone for sins
|
yuuji@0
|
261 . March Mars, god of war
|
yuuji@0
|
262 . April Latin "aperire" => "to open" buds
|
yuuji@0
|
263 . May Maia, goddess of plant growth
|
yuuji@0
|
264 . June Latin "juvenis" => "youth"
|
yuuji@0
|
265 . July Julius Caesar
|
yuuji@0
|
266 . August Augustus Caesar
|
yuuji@0
|
267 . September Latin "septem" => "seven"
|
yuuji@0
|
268 . October Latin "octo" => "eight"
|
yuuji@0
|
269 . November Latin "novem" => "nine"
|
yuuji@0
|
270 . December Latin "decem" => "ten"
|
yuuji@0
|
271
|
yuuji@0
|
272 As you'll notice, the last four months are numbered 7 to 10, which
|
yuuji@0
|
273 is an artifact of the time when the new year started in March.
|
yuuji@0
|
274
|
yuuji@0
|
275
|
yuuji@0
|
276 INTERESTING FORMULAE
|
yuuji@0
|
277
|
yuuji@0
|
278 There's another reason why the historical starting of the new year
|
yuuji@0
|
279 is significant. Starting with March, the length of months follows a
|
yuuji@0
|
280 mathematical series:
|
yuuji@0
|
281 31 30 31 30 31 31 30 31 30 31 31 28
|
yuuji@0
|
282
|
yuuji@0
|
283 This means that you can calculate the day of week for any
|
yuuji@0
|
284 arbitrary day/month/year of the Gregorian calendar with the following
|
yuuji@0
|
285 formula (note all divisions are integral):
|
yuuji@0
|
286 _ _
|
yuuji@0
|
287 | 7 + 31*(m - 1) y y y |
|
yuuji@0
|
288 dow = | d + -------------- + y + - - --- + --- | MOD 7
|
yuuji@0
|
289 |_ 12 4 100 400_|
|
yuuji@0
|
290 where
|
yuuji@0
|
291 d := day of month (1..31)
|
yuuji@0
|
292 m := month in old style (March = 1..February = 12)
|
yuuji@0
|
293 y := year in old style
|
yuuji@0
|
294 dow := day of week (Tuesday = 0..Monday = 6)
|
yuuji@0
|
295
|
yuuji@0
|
296 To convert from new style month/year to old style:
|
yuuji@0
|
297 if (m > 2) m -= 2; /* Mar-Dec: subtract 2 from month */
|
yuuji@0
|
298 else m += 10,y--; /* Jan-Feb: months 11 & 12 of previous year */
|
yuuji@0
|
299
|
yuuji@0
|
300 Here's another fun formula. To find the number of days between two
|
yuuji@0
|
301 days, calculate a pair of calendar days with the formula (again, all
|
yuuji@0
|
302 divisions are integral), using new style month/year this time:
|
yuuji@0
|
303 m
|
yuuji@0
|
304 m + -
|
yuuji@0
|
305 8 y y y
|
yuuji@0
|
306 d + 30 * (m - 1) + ----- + y * 365 + - - --- + --- - ld
|
yuuji@0
|
307 2 4 100 400
|
yuuji@0
|
308
|
yuuji@0
|
309 where:
|
yuuji@0
|
310 d := day of month (1..31)
|
yuuji@0
|
311 m := month in new style (January = 1..December = 12)
|
yuuji@0
|
312 y := year in new style
|
yuuji@0
|
313 ld := leap day correction factor:
|
yuuji@0
|
314 0 for January and February in non-leap years
|
yuuji@0
|
315 1 for January and February in leap years
|
yuuji@0
|
316 2 for all other months in all years
|
yuuji@0
|
317
|
yuuji@0
|
318 In C code, the leap day correction factor is calculated as:
|
yuuji@0
|
319 (m < 3) ? !(y % 4) && ((y % 100) || !(y % 400)) : 2
|
yuuji@0
|
320
|
yuuji@0
|
321 It's up to you to figure out how to adapt these formulas for the
|
yuuji@0
|
322 Y4K bugfix and the Orthodox calendar. If you're really clever, try to
|
yuuji@0
|
323 use these formulae to implement the C library ctime(), gmtime(), and
|
yuuji@0
|
324 mktime() functions. Most C library implementations use a table of the
|
yuuji@0
|
325 number of days in a month. You don't need it.
|
yuuji@0
|
326
|
yuuji@0
|
327
|
yuuji@0
|
328 ACKNOWLEDGEMENT:
|
yuuji@0
|
329
|
yuuji@0
|
330 The original version is from an old Digital Equipment Corporation SPR
|
yuuji@0
|
331 answer for VMS. Modifications for c-client, and additional information
|
yuuji@0
|
332 added by Mark Crispin.
|