(Download): Renamed from "Anonymous FTP"; modify for
[elisp/apel.git] / timezone.el
1 ;;; timezone.el --- time zone package for GNU Emacs
2
3 ;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
4
5 ;; Author: Masanobu Umeda
6 ;; Maintainer: umerin@mse.kyutech.ac.jp
7 ;; Keywords: news
8
9 ;; This file is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; This file is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 ;;; Commentary:
24
25 ;; Modified 1 February 1994 by Kyle Jones to fix broken
26 ;; timezone-floor function.
27
28 ;; Modified 25 January 1994 by Kyle Jones so that it will
29 ;; work under version 18 of Emacs.  Provided timezone-floor
30 ;; and timezone-abs functions.
31
32 ;; Modified 4 October 1999 by Yuuichi Teranishi so that it will
33 ;; work with old GNUS 3.14.4 under version 18 of Emacs.
34
35 ;;; Code:
36
37 (defvar timezone-world-timezones
38   '(("PST" .  -800)
39     ("PDT" .  -700)
40     ("MST" .  -700)
41     ("MDT" .  -600)
42     ("CST" .  -600)
43     ("CDT" .  -500)
44     ("EST" .  -500)
45     ("EDT" .  -400)
46     ("AST" .  -400)                     ;by <clamen@CS.CMU.EDU>
47     ("NST" .  -330)                     ;by <clamen@CS.CMU.EDU>
48     ("UT"  .  +000)
49     ("GMT" .  +000)
50     ("BST" .  +100)
51     ("MET" .  +100)
52     ("EET" .  +200)
53     ("JST" .  +900)
54     ("GMT+1"  .  +100) ("GMT+2"  .  +200) ("GMT+3"  .  +300)
55     ("GMT+4"  .  +400) ("GMT+5"  .  +500) ("GMT+6"  .  +600)
56     ("GMT+7"  .  +700) ("GMT+8"  .  +800) ("GMT+9"  .  +900)
57     ("GMT+10" . +1000) ("GMT+11" . +1100) ("GMT+12" . +1200) ("GMT+13" . +1300)
58     ("GMT-1"  .  -100) ("GMT-2"  .  -200) ("GMT-3"  .  -300)
59     ("GMT-4"  .  -400) ("GMT-5"  .  -500) ("GMT-6"  .  -600)
60     ("GMT-7"  .  -700) ("GMT-8"  .  -800) ("GMT-9"  .  -900)
61     ("GMT-10" . -1000) ("GMT-11" . -1100) ("GMT-12" . -1200))
62   "*Time differentials of timezone from GMT in +-HHMM form.
63 This list is obsolescent, and is present only for backwards compatibility,
64 because time zone names are ambiguous in practice.
65 Use `current-time-zone' instead.")
66
67 (defvar timezone-months-assoc
68   '(("JAN" .  1)("FEB" .  2)("MAR" .  3)
69     ("APR" .  4)("MAY" .  5)("JUN" .  6)
70     ("JUL" .  7)("AUG" .  8)("SEP" .  9)
71     ("OCT" . 10)("NOV" . 11)("DEC" . 12))
72   "Alist of first three letters of a month and its numerical representation.")
73
74 (defun timezone-make-date-arpa-standard (date &optional local timezone)
75   "Convert DATE to an arpanet standard date.
76 Optional 2nd argument LOCAL specifies the default local timezone of the DATE;
77 if nil, GMT is assumed.
78 Optional 3rd argument TIMEZONE specifies a time zone to be represented in;
79 if nil, the local time zone is assumed."
80   (let ((new (timezone-fix-time date local timezone)))
81     (timezone-make-arpa-date (aref new 0) (aref new 1) (aref new 2)
82                              (timezone-make-time-string
83                               (aref new 3) (aref new 4) (aref new 5))
84                              (aref new 6))
85     ))
86
87 (defun timezone-make-date-sortable (date &optional local timezone)
88   "Convert DATE to a sortable date string.
89 Optional 2nd argument LOCAL specifies the default local timezone of the DATE;
90 if nil, GMT is assumed.
91 Optional 3rd argument TIMEZONE specifies a timezone to be represented in;
92 if nil, the local time zone is assumed."
93   (let ((new (timezone-fix-time date local timezone)))
94     (timezone-make-sortable-date (aref new 0) (aref new 1) (aref new 2)
95                                  (timezone-make-time-string
96                                   (aref new 3) (aref new 4) (aref new 5)))
97     ))
98
99 \f
100 ;;
101 ;; Parsers and Constructors of Date and Time
102 ;;
103
104 (defun timezone-make-arpa-date (year month day time &optional timezone)
105   "Make arpanet standard date string from YEAR, MONTH, DAY, and TIME.
106 Optional argument TIMEZONE specifies a time zone."
107   (let ((zone
108          (if (listp timezone)
109              (let* ((m (timezone-zone-to-minute timezone))
110                     (absm (if (< m 0) (- m) m)))
111                (format "%c%02d%02d"
112                        (if (< m 0) ?- ?+) (/ absm 60) (% absm 60)))
113            timezone)))
114     (format "%02d %s %04d %s %s"
115             day
116             (capitalize (car (rassq month timezone-months-assoc)))
117             year
118             time
119             zone)))
120
121 (defun timezone-make-sortable-date (year month day time)
122   "Make sortable date string from YEAR, MONTH, DAY, and TIME."
123   (format "%4d%02d%02d%s"
124           year month day time))
125
126 (defun timezone-make-time-string (hour minute second)
127   "Make time string from HOUR, MINUTE, and SECOND."
128   (format "%02d:%02d:%02d" hour minute second))
129
130 (defun timezone-parse-date (date)
131   "Parse DATE and return a vector [YEAR MONTH DAY TIME TIMEZONE].
132 19 is prepended to year if necessary.  Timezone may be nil if nothing.
133 Understands the following styles:
134  (1) 14 Apr 89 03:20[:12] [GMT]
135  (2) Fri, 17 Mar 89 4:01[:33] [GMT]
136  (3) Mon Jan 16 16:12[:37] [GMT] 1989
137  (4) 6 May 1992 1641-JST (Wednesday)
138  (5) 22-AUG-1993 10:59:12.82
139  (6) Thu, 11 Apr 16:17:12 91 [MET]
140  (7) Mon, 6  Jul 16:47:20 T 1992 [MET]
141  (8) 1996-06-24 21:13:12 [GMT]
142  (9) 1996-06-24 21:13-ZONE"
143  ;; Get rid of any text properties.
144   (and (stringp date)
145        (or (text-properties-at 0 date)
146            (next-property-change 0 date))
147        (setq date (copy-sequence date))
148        (set-text-properties 0 (length date) nil date))
149   (let ((date (or date ""))
150         (year nil)
151         (month nil)
152         (day nil)
153         (time nil)
154         (zone nil))                     ;This may be nil.
155     (cond ((string-match
156             "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date)
157            ;; Styles: (1) and (2) with timezone and buggy timezone
158            ;; This is most common in mail and news,
159            ;; so it is worth trying first.
160            (setq year 3 month 2 day 1 time 4 zone 5))
161           ((string-match
162             "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]*\\'" date)
163            ;; Styles: (1) and (2) without timezone
164            (setq year 3 month 2 day 1 time 4 zone nil))
165           ((string-match
166             "\\([^ \t,]+\\),[ \t]+\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\(T[ \t]+\\|\\)\\([0-9]+\\)[ \t]*\\'" date)
167            ;; Styles: (6) and (7) without timezone
168            (setq year 6 month 3 day 2 time 4 zone nil))
169           ((string-match
170             "\\([^ \t,]+\\),[ \t]+\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\(T[ \t]+\\|\\)\\([0-9]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date)
171            ;; Styles: (6) and (7) with timezone and buggy timezone
172            (setq year 6 month 3 day 2 time 4 zone 7))
173           ((string-match
174             "\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\([0-9]+\\)" date)
175            ;; Styles: (3) without timezone
176            (setq year 4 month 1 day 2 time 3 zone nil))
177           ((string-match
178             "\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\([-+a-zA-Z0-9]+\\)[ \t]+\\([0-9]+\\)" date)
179            ;; Styles: (3) with timezone
180            (setq year 5 month 1 day 2 time 3 zone 4))
181           ((string-match
182             "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date)
183            ;; Styles: (4) with timezone
184            (setq year 3 month 2 day 1 time 4 zone 5))
185           ((string-match
186             "\\([0-9]+\\)-\\([A-Za-z]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+:[0-9]+\\)\\(\\.[0-9]+\\)?[ \t]+\\([-+a-zA-Z0-9]+\\)" date)
187            ;; Styles: (5) with timezone.
188            (setq year 3 month 2 day 1 time 4 zone 6))
189           ((string-match
190             "\\([0-9]+\\)-\\([A-Za-z]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+:[0-9]+\\)\\(\\.[0-9]+\\)?" date)
191            ;; Styles: (5) without timezone.
192            (setq year 3 month 2 day 1 time 4 zone nil))
193           ((string-match
194             "\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+:[0-9]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date)
195            ;; Styles: (8) with timezone.
196            (setq year 1 month 2 day 3 time 4 zone 5))
197           ((string-match
198             "\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+\\)[ \t]*\\([-+a-zA-Z0-9:]+\\)" date)
199            ;; Styles: (8) with timezone with a colon in it.
200            (setq year 1 month 2 day 3 time 4 zone 5))
201           ((string-match
202             "\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+:[0-9]+\\)" date)
203            ;; Styles: (8) without timezone.
204            (setq year 1 month 2 day 3 time 4 zone nil))
205           )
206     (when year
207       (setq year (match-string year date))
208       ;; Guess ambiguous years.  Assume years < 69 don't predate the
209       ;; Unix Epoch, so are 2000+.  Three-digit years are assumed to
210       ;; be relative to 1900.
211       (if (< (length year) 4)
212           (let ((y (string-to-int year)))
213             (if (< y 69)
214                 (setq y (+ y 100)))
215             (setq year (int-to-string (+ 1900 y)))))
216       (setq month
217             (if (= (aref date (+ (match-beginning month) 2)) ?-)
218                 ;; Handle numeric months, spanning exactly two digits.
219                 (substring date
220                            (match-beginning month)
221                            (+ (match-beginning month) 2))
222               (let* ((string (substring date
223                                         (match-beginning month)
224                                         (+ (match-beginning month) 3)))
225                      (monthnum
226                       (cdr (assoc (upcase string) timezone-months-assoc))))
227                 (if monthnum
228                     (int-to-string monthnum)))))
229       (setq day (match-string day date))
230       (setq time (match-string time date)))
231     (if zone (setq zone (match-string zone date)))
232     ;; Return a vector.
233     (if (and year month)
234         (vector year month day time zone)
235       (vector "0" "0" "0" "0" nil))))
236
237 (defun timezone-parse-time (time)
238   "Parse TIME (HH:MM:SS) and return a vector [hour minute second].
239 Recognize HH:MM:SS, HH:MM, HHMMSS, HHMM."
240   (let ((time (or time ""))
241         (hour nil)
242         (minute nil)
243         (second nil))
244     (cond ((string-match "\\`\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\)\\'" time)
245            ;; HH:MM:SS
246            (setq hour 1 minute 2 second 3))
247           ((string-match "\\`\\([0-9]+\\):\\([0-9]+\\)\\'" time)
248            ;; HH:MM
249            (setq hour 1 minute 2 second nil))
250           ((string-match "\\`\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\'" time)
251            ;; HHMMSS
252            (setq hour 1 minute 2 second 3))
253           ((string-match "\\`\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\'" time)
254            ;; HHMM
255            (setq hour 1 minute 2 second nil))
256           )
257     ;; Return [hour minute second]
258     (vector
259      (if hour
260          (substring time (match-beginning hour) (match-end hour)) "0")
261      (if minute
262          (substring time (match-beginning minute) (match-end minute)) "0")
263      (if second
264          (substring time (match-beginning second) (match-end second)) "0"))
265     ))
266
267 \f
268 ;; Miscellaneous
269
270 (defun timezone-zone-to-minute (timezone)
271   "Translate TIMEZONE to an integer minute offset from GMT.
272 TIMEZONE can be a cons cell containing the output of `current-time-zone',
273 or an integer of the form +-HHMM, or a time zone name."
274   (cond
275      ((consp timezone)
276       (/ (car timezone) 60))
277      (timezone
278       (progn
279         (setq timezone
280               (or (and (stringp timezone) (cdr (assoc (upcase timezone) timezone-world-timezones)))
281                   ;; +900
282                   timezone))
283         (if (stringp timezone)
284             (setq timezone (string-to-int timezone)))
285         ;; Taking account of minute in timezone.
286         ;; HHMM -> MM
287         (let* ((abszone (abs timezone))
288                (minutes (+ (* 60 (/ abszone 100)) (% abszone 100))))
289           (if (< timezone 0) (- minutes) minutes))))
290      (t 0)))
291
292 (defun timezone-floor (arg &optional divisor)
293   "Return the largest integer no grater than ARG.
294 With optional DIVISOR, return the largest integer no greater than ARG/DIVISOR."
295   (if (null divisor)
296       (setq divisor 1))
297   (if (< arg 0)
298       (- (/ (- divisor 1 arg) divisor))
299     (/ arg divisor)))
300
301 (defun timezone-time-from-absolute (date seconds)
302   "Compute the UTC time equivalent to DATE at time SECONDS after midnight.
303 Return a list suitable as an argument to `current-time-zone',
304 or nil if the date cannot be thus represented.
305 DATE is the number of days elapsed since the (imaginary)
306 Gregorian date Sunday, December 31, 1 BC."
307   (let* ((current-time-origin 719163)
308             ;; (timezone-absolute-from-gregorian 1 1 1970)
309          (days (- date current-time-origin))
310          (days-1 (/ days 65536))
311          (days-2 (% (/ days 256) 256))
312          (days-3 (% days 256))
313          ;; (seconds-per-day (float 86400))
314          (seconds-per-day-1 1)
315          (seconds-per-day-2 81)
316          (seconds-per-day-3 128)
317          ;; (seconds (+ seconds (* days seconds-per-day)))
318          ;; (current-time-arithmetic-base (float 65536))
319          ;; (hi (timezone-floor (/ seconds current-time-arithmetic-base)))
320          ;; (hibase (* hi current-time-arithmetic-base))
321          ;; (lo (timezone-floor (- seconds hibase)))
322          (seconds-1 (/ seconds 65536))
323          (seconds-2 (% (/ seconds 256) 256))
324          (seconds-3 (% seconds 256))
325          hi lo
326          r
327          seconds-per-day*days-1
328          seconds-per-day*days-2
329          seconds-per-day*days-3)
330     (setq r (* days-3 seconds-per-day-3)
331           seconds-per-day*days-3 (% r 256))
332     (setq r (+ (/ r 256)
333                (* days-2 seconds-per-day-3)
334                (* days-3 seconds-per-day-2))
335           seconds-per-day*days-2 (% r 256))
336     (setq seconds-per-day*days-1 (+ (/ r 256)
337                                     (* days-1 seconds-per-day-3)
338                                     (* (/ days 256) seconds-per-day-2)
339                                     (* days seconds-per-day-1)))
340     (setq r (+ seconds-2 seconds-per-day*days-2)
341           seconds-2 (% r 256)
342           seconds-1 (+ seconds-1 (/ r 256)))
343     (setq lo (+ (* seconds-2 256)
344                 seconds-3 seconds-per-day*days-3))
345     (setq hi (+ seconds-1 seconds-per-day*days-1))
346     ;; (and (< (abs (- seconds (+ hibase lo))) 2) ; Check for integer overflow.
347     ;;      (cons hi lo))
348     (cons hi lo)
349     ))
350
351 (defun timezone-time-zone-from-absolute (date seconds)
352   "Compute the local time zone for DATE at time SECONDS after midnight.
353 Return a list in the same format as current-time-zone's result,
354 or nil if the local time zone could not be computed.
355 DATE is the number of days elapsed since the (imaginary)
356 Gregorian date Sunday, December 31, 1 BC."
357    (and (fboundp 'current-time-zone)
358         (let ((utc-time (timezone-time-from-absolute date seconds)))
359           (and utc-time
360                (let ((zone (current-time-zone utc-time)))
361                  (and (car zone) zone))))))
362
363 (defsubst timezone-fix-time-1 (year month day hour minute second)
364   "Fix date and time.
365 For old `timezone-fix-time' function.
366 Arguments are YEAR, MONTH, DAY, HOUR, MINUTE and SECOND."
367   ;; MINUTE may be larger than 60 or smaller than -60.
368   (let ((hour-fix
369          (if (< minute 0)
370              ;;(/ (- minute 59) 60) (/ minute 60)
371              ;; ANSI C compliance about truncation of integer division
372              ;; by eggert@twinsun.com (Paul Eggert)
373              (- (/ (- 59 minute) 60)) (/ minute 60))))
374     (setq hour (+ hour hour-fix))
375     (setq minute (- minute (* 60 hour-fix))))
376   ;; HOUR may be larger than 24 or smaller than 0.
377   (cond ((<= 24 hour)                   ;24 -> 00
378          (setq hour (- hour 24))
379          (setq day  (1+ day))
380          (if (< (timezone-last-day-of-month month year) day)
381              (progn
382                (setq month (1+ month))
383                (setq day 1)
384                (if (< 12 month)
385                    (progn
386                      (setq month 1)
387                      (setq year (1+ year))
388                      ))
389                )))
390         ((> 0 hour)
391          (setq hour (+ hour 24))
392          (setq day  (1- day))
393          (if (> 1 day)
394              (progn
395                (setq month (1- month))
396                (if (> 1 month)
397                    (progn
398                      (setq month 12)
399                      (setq year (1- year))
400                      ))
401                (setq day (timezone-last-day-of-month month year))
402                )))
403         )
404   (vector year month day hour minute second))
405
406 (defsubst timezone-fix-time-2 (date local timezone)
407   "Convert DATE (default timezone LOCAL) to YYYY-MM-DD-HH-MM-SS-ZONE vector.
408 If LOCAL is nil, it is assumed to be GMT.
409 If TIMEZONE is nil, use the local time zone."
410   (let* ((date   (timezone-parse-date date))
411          (year   (string-to-int (aref date 0)))
412          (year   (cond ((< year 50)
413                         (+ year 2000))
414                        ((< year 100)
415                         (+ year 1900))
416                        (t year)))
417          (month  (string-to-int (aref date 1)))
418          (day    (string-to-int (aref date 2)))
419          (time   (timezone-parse-time (aref date 3)))
420          (hour   (string-to-int (aref time 0)))
421          (minute (string-to-int (aref time 1)))
422          (second (string-to-int (aref time 2)))
423          (local  (or (aref date 4) local)) ;Use original if defined
424          (timezone
425           (or timezone
426               (timezone-time-zone-from-absolute
427                (timezone-absolute-from-gregorian month day year)
428                (+ second (* 60 (+ minute (* 60 hour)))))))
429          (diff   (- (timezone-zone-to-minute timezone)
430                     (timezone-zone-to-minute local)))
431          (minute (+ minute diff))
432          (hour-fix (timezone-floor minute 60)))
433     (setq hour (+ hour hour-fix))
434     (setq minute (- minute (* 60 hour-fix)))
435     ;; HOUR may be larger than 24 or smaller than 0.
436     (cond ((<= 24 hour)                 ;24 -> 00
437            (setq hour (- hour 24))
438            (setq day  (1+ day))
439            (if (< (timezone-last-day-of-month month year) day)
440                (progn
441                  (setq month (1+ month))
442                  (setq day 1)
443                  (if (< 12 month)
444                      (progn
445                        (setq month 1)
446                        (setq year (1+ year))
447                        ))
448                  )))
449           ((> 0 hour)
450            (setq hour (+ hour 24))
451            (setq day  (1- day))
452            (if (> 1 day)
453                (progn
454                  (setq month (1- month))
455                  (if (> 1 month)
456                      (progn
457                        (setq month 12)
458                        (setq year (1- year))
459                        ))
460                  (setq day (timezone-last-day-of-month month year))
461                  )))
462           )
463     (vector year month day hour minute second timezone)))
464
465 (defun timezone-fix-time (a1 a2 a3 &optional a4 a5 a6)
466   "Fix date and time.
467 (Old API: A1=YEAR A2=MONTH A3=DAY A4=HOUR A5=MINUTE A6=SECOND).
468 Convert DATE (default timezone LOCAL) to YYYY-MM-DD-HH-MM-SS-ZONE vector.
469 If LOCAL is nil, it is assumed to be GMT.
470 If TIMEZONE is nil, use the local time zone.
471 (New API: A1=DATE A2=LOCAL A3=TIMEZONE)"
472   (if a4
473       (timezone-fix-time-1 a1 a2 a3 a4 a5 a6)
474     (timezone-fix-time-2 a1 a2 a3)))
475
476 ;; Partly copied from Calendar program by Edward M. Reingold.
477 ;; Thanks a lot.
478
479 (defun timezone-last-day-of-month (month year)
480   "The last day in MONTH during YEAR."
481   (if (and (= month 2) (timezone-leap-year-p year))
482       29
483     (aref [31 28 31 30 31 30 31 31 30 31 30 31] (1- month))))
484
485 (defun timezone-leap-year-p (year)
486   "Return t if YEAR is a Gregorian leap year."
487   (or (and (zerop  (% year 4))
488            (not (zerop (% year 100))))
489       (zerop (% year 400))))
490
491 (defun timezone-day-number (month day year)
492   "Return the day number within the year of the date MONTH/DAY/YEAR."
493   (let ((day-of-year (+ day (* 31 (1- month)))))
494     (if (> month 2)
495         (progn
496           (setq day-of-year (- day-of-year (/ (+ 23 (* 4 month)) 10)))
497           (if (timezone-leap-year-p year)
498               (setq day-of-year (1+ day-of-year)))))
499     day-of-year))
500
501 (defun timezone-absolute-from-gregorian (month day year)
502   "The number of days between the Gregorian date 12/31/1 BC and MONTH/DAY/YEAR.
503 The Gregorian date Sunday, December 31, 1 BC is imaginary."
504   (+ (timezone-day-number month day year);; Days this year
505      (* 365 (1- year));;        + Days in prior years
506      (/ (1- year) 4);;          + Julian leap years
507      (- (/ (1- year) 100));;    - century years
508      (/ (1- year) 400)));;      + Gregorian leap years
509
510 ;;; @ End.
511 ;;;
512
513 (require 'product)
514 (product-provide (provide 'timezone) (require 'apel-ver))
515
516 ;;; timezone.el ends here