(date-to-time): Add autoload cookie. Canonicalize with
timezone-make-date-arpa-standard.
(time-to-seconds): Avoid caddr.
(safe-date-to-time): Add autoload cookie.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Masanobu Umeda <umerin@mse.kyutech.ac.jp>
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Masanobu Umeda <umerin@mse.kyutech.ac.jp>
+;; Keywords: mail news util
+
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
+(autoload 'timezone-make-date-arpa-standard "timezone")
+
+;;;###autoload
(defun date-to-time (date)
"Convert DATE into time."
(condition-case ()
(defun date-to-time (date)
"Convert DATE into time."
(condition-case ()
- (apply 'encode-time (parse-time-string date))
+ ;; `timezone-make-date-arpa-standard' makes this more robust,
+ ;; e.g. against the crop of year 100 dates in Jan 2000.
+ (apply 'encode-time (parse-time-string
+ (timezone-make-date-arpa-standard date)))
(error (error "Invalid date: %s" date))))
(defun time-to-seconds (time)
"Convert TIME to a floating point number."
(+ (* (car time) 65536.0)
(cadr time)
(error (error "Invalid date: %s" date))))
(defun time-to-seconds (time)
"Convert TIME to a floating point number."
(+ (* (car time) 65536.0)
(cadr time)
- (/ (or (caddr time) 0) 1000000.0)))
+ (/ (or (nth 2 time) 0) 1000000.0)))
(defun seconds-to-time (seconds)
"Convert SECONDS (a floating point number) to an Emacs time structure."
(defun seconds-to-time (seconds)
"Convert SECONDS (a floating point number) to an Emacs time structure."
(- (/ (1- year) 100)) ; - century years
(/ (1- year) 400)))) ; + Gregorian leap years
(- (/ (1- year) 100)) ; - century years
(/ (1- year) 400)))) ; + Gregorian leap years
(defun safe-date-to-time (date)
"Parse DATE and return a time structure.
If DATE is malformed, a zero time will be returned."
(defun safe-date-to-time (date)
"Parse DATE and return a time structure.
If DATE is malformed, a zero time will be returned."