aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/timezone.el
diff options
context:
space:
mode:
authorDave Love2000-10-08 16:26:04 +0000
committerDave Love2000-10-08 16:26:04 +0000
commitca87e9606ad5c38ac0972b0abc633e5a739b5aa3 (patch)
tree6bf56369504bb780db1f4f801ca268b2a5a62c18 /lisp/timezone.el
parent3a6d7a0dc964ed48f0b311c30336db78a9488df4 (diff)
downloademacs-ca87e9606ad5c38ac0972b0abc633e5a739b5aa3.tar.gz
emacs-ca87e9606ad5c38ac0972b0abc633e5a739b5aa3.zip
(timezone-parse-date): Doc fix. Fix regexps for (5)
without timezone and (8) with timezone to enforce some whitespace. Simplify code somewhat.
Diffstat (limited to 'lisp/timezone.el')
-rw-r--r--lisp/timezone.el42
1 files changed, 18 insertions, 24 deletions
diff --git a/lisp/timezone.el b/lisp/timezone.el
index d6473158f36..66e62b1af0f 100644
--- a/lisp/timezone.el
+++ b/lisp/timezone.el
@@ -120,7 +120,10 @@ Optional argument TIMEZONE specifies a time zone."
120 120
121(defun timezone-parse-date (date) 121(defun timezone-parse-date (date)
122 "Parse DATE and return a vector [YEAR MONTH DAY TIME TIMEZONE]. 122 "Parse DATE and return a vector [YEAR MONTH DAY TIME TIMEZONE].
12319 is prepended to year if necessary. Timezone may be nil if nothing. 123Two-digit dates are `windowed'. Those <69 have 2000 added; otherwise 1900
124is added. Three-digit dates have 1900 added.
125TIMEZONE is nil for DATEs without a zone field.
126
124Understands the following styles: 127Understands the following styles:
125 (1) 14 Apr 89 03:20[:12] [GMT] 128 (1) 14 Apr 89 03:20[:12] [GMT]
126 (2) Fri, 17 Mar 89 4:01[:33] [GMT] 129 (2) Fri, 17 Mar 89 4:01[:33] [GMT]
@@ -182,11 +185,11 @@ Understands the following styles:
182 ;; Styles: (5) without timezone. 185 ;; Styles: (5) without timezone.
183 (setq year 3 month 2 day 1 time 4 zone nil)) 186 (setq year 3 month 2 day 1 time 4 zone nil))
184 ((string-match 187 ((string-match
185 "\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+:[0-9]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date) 188 "\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+:[0-9]+\\)[ \t]+\\([-+a-zA-Z0-9]+\\)" date)
186 ;; Styles: (8) with timezone. 189 ;; Styles: (8) with timezone.
187 (setq year 1 month 2 day 3 time 4 zone 5)) 190 (setq year 1 month 2 day 3 time 4 zone 5))
188 ((string-match 191 ((string-match
189 "\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+\\)[ \t]*\\([-+a-zA-Z0-9:]+\\)" date) 192 "\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+\\)[ \t]+\\([-+a-zA-Z0-9:]+\\)" date)
190 ;; Styles: (8) with timezone with a colon in it. 193 ;; Styles: (8) with timezone with a colon in it.
191 (setq year 1 month 2 day 3 time 4 zone 5)) 194 (setq year 1 month 2 day 3 time 4 zone 5))
192 ((string-match 195 ((string-match
@@ -339,30 +342,21 @@ If TIMEZONE is nil, use the local time zone."
339 (cond ((<= 24 hour) ;24 -> 00 342 (cond ((<= 24 hour) ;24 -> 00
340 (setq hour (- hour 24)) 343 (setq hour (- hour 24))
341 (setq day (1+ day)) 344 (setq day (1+ day))
342 (if (< (timezone-last-day-of-month month year) day) 345 (when (< (timezone-last-day-of-month month year) day)
343 (progn 346 (setq month (1+ month))
344 (setq month (1+ month)) 347 (setq day 1)
345 (setq day 1) 348 (when (< 12 month)
346 (if (< 12 month) 349 (setq month 1)
347 (progn 350 (setq year (1+ year)))))
348 (setq month 1)
349 (setq year (1+ year))
350 ))
351 )))
352 ((> 0 hour) 351 ((> 0 hour)
353 (setq hour (+ hour 24)) 352 (setq hour (+ hour 24))
354 (setq day (1- day)) 353 (setq day (1- day))
355 (if (> 1 day) 354 (when (> 1 day)
356 (progn 355 (setq month (1- month))
357 (setq month (1- month)) 356 (when (> 1 month)
358 (if (> 1 month) 357 (setq month 12)
359 (progn 358 (setq year (1- year)))
360 (setq month 12) 359 (setq day (timezone-last-day-of-month month year)))))
361 (setq year (1- year))
362 ))
363 (setq day (timezone-last-day-of-month month year))
364 )))
365 )
366 (vector year month day hour minute second timezone))) 360 (vector year month day hour minute second timezone)))
367 361
368;; Partly copied from Calendar program by Edward M. Reingold. 362;; Partly copied from Calendar program by Edward M. Reingold.