X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Ftime-date.el;h=3bfb9a454d04565e42f0e557b1c9988ad96b4e23;hb=1f2b93a24df7b9914dbbc1a26a6e76c8da6511d1;hp=448bc5405ffd9b7bbbba475bde6e644341bd6862;hpb=6f36be6edb77c6439801f7392b777715cb778d08;p=elisp%2Fgnus.git- diff --git a/lisp/time-date.el b/lisp/time-date.el index 448bc54..3bfb9a4 100644 --- a/lisp/time-date.el +++ b/lisp/time-date.el @@ -1,8 +1,10 @@ ;;; time-date.el --- Date and time handling functions -;; Copyright (C) 1998,99 Free Software Foundation, Inc. +;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. ;; Author: Lars Magne Ingebrigtsen ;; Masanobu Umeda +;; Keywords: mail news util + ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify @@ -24,20 +26,30 @@ ;;; Code: -(eval-when-compile (require 'cl)) (require 'parse-time) +(autoload 'timezone-make-date-arpa-standard "timezone") + +;;;###autoload (defun date-to-time (date) "Convert DATE into time." (condition-case () - (apply 'encode-time (parse-time-string date)) + (apply 'encode-time + (parse-time-string + ;; `parse-time-string' isn't sufficiently general or + ;; robust. It fails to grok some of the formats that + ;; timzeone does (e.g. dodgy post-2000 stuff from some + ;; Elms) and either fails or returns bogus values. Lars + ;; reverted this change, but that loses non-trivially + ;; often for me. -- fx + (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) - (/ (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." @@ -117,6 +129,7 @@ The Gregorian date Sunday, December 31, 1bce is imaginary." (- (/ (1- year) 100)) ; - century years (/ (1- year) 400)))) ; + Gregorian leap years +;;;###autoload (defun safe-date-to-time (date) "Parse DATE and return a time structure. If DATE is malformed, a zero time will be returned."