;;; time-date.el --- Date and time handling functions
-;; Copyright (C) 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1998,99 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Masanobu Umeda <umerin@mse.kyutech.ac.jp>
(defun date-to-day (date)
"Return the number of days between year 1 and DATE."
- (time-to-day (date-to-time date)))
-
+ (time-to-days (date-to-time date)))
+
(defun days-between (date1 date2)
"Return the number of days between DATE1 and DATE2."
(- (date-to-day date1) (date-to-day date2)))
(setq day-of-year (1+ day-of-year))))
day-of-year))
-(defun time-to-day (time)
+(defun time-to-days (time)
"The number of days between the Gregorian date 0001-12-31bce and TIME.
The Gregorian date Sunday, December 31, 1bce is imaginary."
(let* ((tim (decode-time time))
(- (/ (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."
+ (condition-case ()
+ (date-to-time date)
+ (error '(0 0))))
+
(provide 'time-date)
;;; time-date.el ends here