comparison lisp/utils/timezone.el @ 86:364816949b59 r20-0b93

Import from CVS: tag r20-0b93
author cvs
date Mon, 13 Aug 2007 09:09:02 +0200
parents 6a378aca36af
children 43dd3413c7c7
comparison
equal deleted inserted replaced
85:c661705957e0 86:364816949b59
127 127
128 (defun timezone-make-time-string (hour minute second) 128 (defun timezone-make-time-string (hour minute second)
129 "Make time string from HOUR, MINUTE, and SECOND." 129 "Make time string from HOUR, MINUTE, and SECOND."
130 (format "%02d:%02d:%02d" hour minute second)) 130 (format "%02d:%02d:%02d" hour minute second))
131 131
132 ;;;###autoload
133 (define-error 'invalid-date "Invalid date string")
134
132 (defun timezone-parse-date (date) 135 (defun timezone-parse-date (date)
133 "Parse DATE and return a vector [YEAR MONTH DAY TIME TIMEZONE]. 136 "Parse DATE and return a vector [YEAR MONTH DAY TIME TIMEZONE].
134 19 is prepended to year if necessary. Timezone may be nil if nothing. 137 19 is prepended to year if necessary. Timezone may be nil if nothing.
135 Understands the following styles: 138 Understands the following styles:
136 (1) 14 Apr 89 03:20[:12] [GMT] 139 (1) 14 Apr 89 03:20[:12] [GMT]
138 (3) Mon Jan 16 16:12[:37] [GMT] 1989 141 (3) Mon Jan 16 16:12[:37] [GMT] 1989
139 (4) 6 May 1992 1641-JST (Wednesday) 142 (4) 6 May 1992 1641-JST (Wednesday)
140 (5) 22-AUG-1993 10:59:12.82 143 (5) 22-AUG-1993 10:59:12.82
141 (6) Thu, 11 Apr 16:17:12 91 [MET] 144 (6) Thu, 11 Apr 16:17:12 91 [MET]
142 (7) Mon, 6 Jul 16:47:20 T 1992 [MET]" 145 (7) Mon, 6 Jul 16:47:20 T 1992 [MET]"
146 (condition-case nil
147 (progn
143 ;; Get rid of any text properties. 148 ;; Get rid of any text properties.
144 (and (stringp date) 149 (and (stringp date)
145 (or (text-properties-at 0 date) 150 (or (text-properties-at 0 date)
146 (next-property-change 0 date)) 151 (next-property-change 0 date))
147 (setq date (copy-sequence date)) 152 (setq date (copy-sequence date))
217 (substring date (match-beginning zone) (match-end zone)))) 222 (substring date (match-beginning zone) (match-end zone))))
218 ;; Return a vector. 223 ;; Return a vector.
219 (if year 224 (if year
220 (vector year month day time zone) 225 (vector year month day time zone)
221 (vector "0" "0" "0" "0" nil)) 226 (vector "0" "0" "0" "0" nil))
222 )) 227 )
228 )
229 (t (signal 'invalid-date (list date))))
230 )
223 231
224 (defun timezone-parse-time (time) 232 (defun timezone-parse-time (time)
225 "Parse TIME (HH:MM:SS) and return a vector [hour minute second]. 233 "Parse TIME (HH:MM:SS) and return a vector [hour minute second].
226 Recognize HH:MM:SS, HH:MM, HHMMSS, HHMM." 234 Recognize HH:MM:SS, HH:MM, HHMMSS, HHMM."
227 (let ((time (or time "")) 235 (let ((time (or time ""))