comparison lisp/timezone.el @ 4835:4324c797a9e3

(timezone-parse-date): Handle new style 22-AUG-1993.
author Richard M. Stallman <rms@gnu.org>
date Sat, 09 Oct 1993 03:46:09 +0000
parents 10baf5e7550f
children da21af13b844
comparison
equal deleted inserted replaced
4834:f2dc5b8eafa8 4835:4324c797a9e3
116 (defun timezone-make-time-string (hour minute second) 116 (defun timezone-make-time-string (hour minute second)
117 "Make time string from HOUR, MINUTE, and SECOND." 117 "Make time string from HOUR, MINUTE, and SECOND."
118 (format "%02d:%02d:%02d" hour minute second)) 118 (format "%02d:%02d:%02d" hour minute second))
119 119
120 (defun timezone-parse-date (date) 120 (defun timezone-parse-date (date)
121 "Parse DATE and return a vector [year month day time timezone]. 121 "Parse DATE and return a vector [YEAR MONTH DAY TIME TIMEZONE].
122 19 is prepended to year if necessary. Timezone may be NIL if nothing. 122 19 is prepended to year if necessary. Timezone may be nil if nothing.
123 Understand the following styles: 123 Understands the following styles:
124 (1) 14 Apr 89 03:20[:12] [GMT] 124 (1) 14 Apr 89 03:20[:12] [GMT]
125 (2) Fri, 17 Mar 89 4:01[:33] [GMT] 125 (2) Fri, 17 Mar 89 4:01[:33] [GMT]
126 (3) Mon Jan 16 16:12[:37] [GMT] 1989 126 (3) Mon Jan 16 16:12[:37] [GMT] 1989
127 (4) 6 May 1992 1641-JST (Wednesday)" 127 (4) 6 May 1992 1641-JST (Wednesday)
128 (5) 22-AUG-1993 10:59:12.82"
128 (let ((date (or date "")) 129 (let ((date (or date ""))
129 (year nil) 130 (year nil)
130 (month nil) 131 (month nil)
131 (day nil) 132 (day nil)
132 (time nil) 133 (time nil)
143 "\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\([0-9]+\\)" date) 144 "\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\([0-9]+\\)" date)
144 ;; Styles: (3) without timezone 145 ;; Styles: (3) without timezone
145 (setq year 4 month 1 day 2 time 3 zone nil)) 146 (setq year 4 month 1 day 2 time 3 zone nil))
146 ((string-match 147 ((string-match
147 "\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\([-+a-zA-Z0-9]+\\)[ \t]+\\([0-9]+\\)" date) 148 "\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9:]+\\)[ \t]+\\([-+a-zA-Z0-9]+\\)[ \t]+\\([0-9]+\\)" date)
148 ;; Styles: (3) with timezoen 149 ;; Styles: (3) with timezone
149 (setq year 5 month 1 day 2 time 3 zone 4)) 150 (setq year 5 month 1 day 2 time 3 zone 4))
150 ((string-match 151 ((string-match
151 "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date) 152 "\\([0-9]+\\)[ \t]+\\([^ \t,]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)[ \t]*\\([-+a-zA-Z0-9]+\\)" date)
152 ;; Styles: (4) with timezone 153 ;; Styles: (4) with timezone
153 (setq year 3 month 2 day 1 time 4 zone 5)) 154 (setq year 3 month 2 day 1 time 4 zone 5))
155 ((string-match
156 "\\([0-9]+\\)-\\([A-Za-z]+\\)-\\([0-9]+\\)[ \t]+\\([0-9]+:[0-9]+:[0-9]+\\)\\.[0-9]+" date)
157 ;; Styles: (5) without timezone.
158 (setq year 3 month 2 day 1 time 4 zone nil))
154 ) 159 )
155 (if year 160 (if year
156 (progn 161 (progn
157 (setq year 162 (setq year
158 (substring date (match-beginning year) (match-end year))) 163 (substring date (match-beginning year) (match-end year)))