comparison lisp/calendar/time-date.el @ 104798:b04b1ea82ee0

(time-to-seconds): In Emacs, make it an obsolete alias for float-time. (time-to-number-of-days): In Emacs, use float-time.
author Glenn Morris <rgm@gnu.org>
date Wed, 02 Sep 2009 03:22:30 +0000
parents a16e9f7c2536
children 2e22af528b76
comparison
equal deleted inserted replaced
104797:cfe03355665f 104798:b04b1ea82ee0
109 ;; reverted this change, but that loses non-trivially 109 ;; reverted this change, but that loses non-trivially
110 ;; often for me. -- fx 110 ;; often for me. -- fx
111 (timezone-make-date-arpa-standard date))) 111 (timezone-make-date-arpa-standard date)))
112 (error (error "Invalid date: %s" date)))) 112 (error (error "Invalid date: %s" date))))
113 113
114 ;;;###autoload 114 ;; Bit of a mess. Emacs has float-time since at least 21.1.
115 (defun time-to-seconds (time) 115 ;; This file is synced to Gnus, and XEmacs packages may have been written
116 "Convert time value TIME to a floating point number. 116 ;; using time-to-seconds from the Gnus library.
117 You can use `float-time' instead." 117 ;;;###autoload(if (featurep 'xemacs)
118 (with-decoded-time-value ((high low micro time)) 118 ;;;###autoload (autoload 'time-to-seconds "time-date")
119 (+ (* 1.0 high 65536) 119 ;;;###autoload (define-obsolete-function-alias 'time-to-seconds 'float-time "21.1"))
120 low 120
121 (/ micro 1000000.0)))) 121 (if (featurep 'xemacs)
122 (defun time-to-seconds (time)
123 "Convert time value TIME to a floating point number."
124 (with-decoded-time-value ((high low micro time))
125 (+ (* 1.0 high 65536)
126 low
127 (/ micro 1000000.0)))))
122 128
123 ;;;###autoload 129 ;;;###autoload
124 (defun seconds-to-time (seconds) 130 (defun seconds-to-time (seconds)
125 "Convert SECONDS (a floating point number) to a time value." 131 "Convert SECONDS (a floating point number) to a time value."
126 (list (floor seconds 65536) 132 (list (floor seconds 65536)
243 (/ (1- year) 400)))) ; + Gregorian leap years 249 (/ (1- year) 400)))) ; + Gregorian leap years
244 250
245 (defun time-to-number-of-days (time) 251 (defun time-to-number-of-days (time)
246 "Return the number of days represented by TIME. 252 "Return the number of days represented by TIME.
247 The number of days will be returned as a floating point number." 253 The number of days will be returned as a floating point number."
248 (/ (time-to-seconds time) (* 60 60 24))) 254 (/ (if (featurep 'xemacs)
255 (time-to-seconds time)
256 (float-time time)) (* 60 60 24)))
249 257
250 ;;;###autoload 258 ;;;###autoload
251 (defun safe-date-to-time (date) 259 (defun safe-date-to-time (date)
252 "Parse a string DATE that represents a date-time and return a time value. 260 "Parse a string DATE that represents a date-time and return a time value.
253 If DATE is malformed, return a time value of zeros." 261 If DATE is malformed, return a time value of zeros."