comparison lisp/calendar/time-date.el @ 92632:870c7b456283

(date-to-time, time-subtract, time-add, safe-date-to-time): Doc fixes.
author Glenn Morris <rgm@gnu.org>
date Sat, 08 Mar 2008 20:22:16 +0000
parents 5f14edcf524f
children 1e3a407766b9
comparison
equal deleted inserted replaced
92631:ff47fbef81f2 92632:870c7b456283
95 (autoload 'parse-time-string "parse-time") 95 (autoload 'parse-time-string "parse-time")
96 (autoload 'timezone-make-date-arpa-standard "timezone") 96 (autoload 'timezone-make-date-arpa-standard "timezone")
97 97
98 ;;;###autoload 98 ;;;###autoload
99 (defun date-to-time (date) 99 (defun date-to-time (date)
100 "Parse a string that represents a date-time and return a time value." 100 "Parse a string DATE that represents a date-time and return a time value."
101 (condition-case () 101 (condition-case ()
102 (apply 'encode-time 102 (apply 'encode-time
103 (parse-time-string 103 (parse-time-string
104 ;; `parse-time-string' isn't sufficiently general or 104 ;; `parse-time-string' isn't sufficiently general or
105 ;; robust. It fails to grok some of the formats that 105 ;; robust. It fails to grok some of the formats that
158 ;;;###autoload 158 ;;;###autoload
159 (defalias 'subtract-time 'time-subtract) 159 (defalias 'subtract-time 'time-subtract)
160 160
161 ;;;###autoload 161 ;;;###autoload
162 (defun time-subtract (t1 t2) 162 (defun time-subtract (t1 t2)
163 "Subtract two time values. 163 "Subtract two time values, T1 minus T2.
164 Return the difference in the format of a time value." 164 Return the difference in the format of a time value."
165 (with-decoded-time-value ((high low micro type t1) 165 (with-decoded-time-value ((high low micro type t1)
166 (high2 low2 micro2 type2 t2)) 166 (high2 low2 micro2 type2 t2))
167 (setq high (- high high2) 167 (setq high (- high high2)
168 low (- low low2) 168 low (- low low2)
176 low (+ low 65536))) 176 low (+ low 65536)))
177 (encode-time-value high low micro type))) 177 (encode-time-value high low micro type)))
178 178
179 ;;;###autoload 179 ;;;###autoload
180 (defun time-add (t1 t2) 180 (defun time-add (t1 t2)
181 "Add two time values. One should represent a time difference." 181 "Add two time values T1 and T2. One should represent a time difference."
182 (with-decoded-time-value ((high low micro type t1) 182 (with-decoded-time-value ((high low micro type t1)
183 (high2 low2 micro2 type2 t2)) 183 (high2 low2 micro2 type2 t2))
184 (setq high (+ high high2) 184 (setq high (+ high high2)
185 low (+ low low2) 185 low (+ low low2)
186 micro (+ micro micro2) 186 micro (+ micro micro2)
246 The number of days will be returned as a floating point number." 246 The number of days will be returned as a floating point number."
247 (/ (time-to-seconds time) (* 60 60 24))) 247 (/ (time-to-seconds time) (* 60 60 24)))
248 248
249 ;;;###autoload 249 ;;;###autoload
250 (defun safe-date-to-time (date) 250 (defun safe-date-to-time (date)
251 "Parse a string that represents a date-time and return a time value. 251 "Parse a string DATE that represents a date-time and return a time value.
252 If DATE is malformed, return a time value of zeros." 252 If DATE is malformed, return a time value of zeros."
253 (condition-case () 253 (condition-case ()
254 (date-to-time date) 254 (date-to-time date)
255 (error '(0 0)))) 255 (error '(0 0))))
256 256