diff lisp/utils/timezone.el @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents 376386a54a3c
children 131b0175ea99
line wrap: on
line diff
--- a/lisp/utils/timezone.el	Mon Aug 13 08:48:43 2007 +0200
+++ b/lisp/utils/timezone.el	Mon Aug 13 08:49:20 2007 +0200
@@ -19,8 +19,9 @@
 ;; General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with XEmacs; see the file COPYING.  If not, write to the Free
-;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with XEmacs; see the file COPYING.  If not, write to the 
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Synched up with: FSF 19.30.
 
@@ -128,6 +129,9 @@
   "Make time string from HOUR, MINUTE, and SECOND."
   (format "%02d:%02d:%02d" hour minute second))
 
+;;;###autoload
+(define-error 'invalid-date "Invalid date string")
+
 (defun timezone-parse-date (date)
   "Parse DATE and return a vector [YEAR MONTH DAY TIME TIMEZONE].
 19 is prepended to year if necessary.  Timezone may be nil if nothing.
@@ -139,6 +143,8 @@
  (5) 22-AUG-1993 10:59:12.82
  (6) Thu, 11 Apr 16:17:12 91 [MET]
  (7) Mon, 6  Jul 16:47:20 T 1992 [MET]"
+  (condition-case nil
+      (progn
   ;; Get rid of any text properties.
   (and (stringp date)
        (or (text-properties-at 0 date)
@@ -190,7 +196,16 @@
 		(substring date (match-beginning year) (match-end year)))
 	  ;; It is now Dec 1992.  8 years before the end of the World.
 	  (if (< (length year) 4)
-	      (setq year (concat "19" (substring year -2 nil))))
+	      ;; 2 digit years are bogus, so guess the century
+	      (let ((yr (string-to-int year)))
+		(when (>= yr 100)
+		  ;; What does a three digit year mean?
+		  (setq yr (- yr 100)))
+		(setq year (format "%d%02d"
+				   (if (< yr 70)
+				       20
+				     19)
+				   yr))))
 	  (let ((string (substring date
 				   (match-beginning month)
 				   (+ (match-beginning month) 3))))
@@ -209,7 +224,10 @@
     (if year
 	(vector year month day time zone)
       (vector "0" "0" "0" "0" nil))
-    ))
+    )
+  )
+    (t (signal 'invalid-date (list date))))
+)
 
 (defun timezone-parse-time (time)
   "Parse TIME (HH:MM:SS) and return a vector [hour minute second].