]> code.delx.au - gnu-emacs/blobdiff - lisp/calc/calc-forms.el
Merge from origin/emacs-24
[gnu-emacs] / lisp / calc / calc-forms.el
index 7cfca261fa31a6b3c93ca2e808ecbaa93abe6d49..a48075cce91041ed1d8c200264cbf01899944588 100644 (file)
@@ -1,6 +1,6 @@
 ;;; calc-forms.el --- data format conversion functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2014 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <daveg@synaptics.com>
 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
        (m (math-normalize (nth 2 a)))
        (s (let ((calc-internal-prec (max (- calc-internal-prec 4) 3)))
             (math-normalize (nth 3 a)))))
-    (if (math-negp h)
+    (if (or 
+         (math-negp h)
+         (and (= h 0) (math-negp m))
+         (and (= h 0) (= m 0) (math-negp s)))
        (progn
          (if (math-posp s)
              (setq s (math-add s -60)
@@ -918,7 +921,7 @@ as measured in the integer number of days before December 31, 1 BC (Gregorian)."
   (catch 'syntax
     (or (math-parse-standard-date math-pd-str t)
        (math-parse-standard-date math-pd-str nil)
-        (and (or (memq 'IYYY calc-date-format) (memq 'Iww calc-date-format))
+        (and (string-match "W[0-9][0-9]" math-pd-str)
              (math-parse-iso-date math-pd-str))
        (and (string-match "\\`[^-+/0-9a-zA-Z]*\\([-+]?[0-9]+\\.?[0-9]*\\([eE][-+]?[0-9]+\\)?\\)[^-+/0-9a-zA-Z]*\\'" math-pd-str)
             (list 'date (math-read-number (math-match-substring math-pd-str 1))))
@@ -943,8 +946,12 @@ as measured in the integer number of days before December 31, 1 BC (Gregorian)."
                    (setq second 0)
                  (setq second (math-read-number second)))
                (if (equal ampm "")
-                   (if (> hour 23)
-                       (throw 'syntax "Hour value out of range"))
+                   (if (or
+                         (> hour 24)
+                         (and (= hour 24)
+                              (not (= minute 0))
+                              (not (eq second 0))))
+                       (throw 'syntax "Hour value is out of range"))
                  (setq ampm (upcase (aref ampm 0)))
                  (if (memq ampm '(?N ?M))
                      (if (and (= hour 12) (= minute 0) (eq second 0))
@@ -952,7 +959,7 @@ as measured in the integer number of days before December 31, 1 BC (Gregorian)."
                        (throw 'syntax
                               "Time must be 12:00:00 in this context"))
                    (if (or (= hour 0) (> hour 12))
-                       (throw 'syntax "Hour value out of range"))
+                       (throw 'syntax "Hour value is out of range"))
                    (if (eq (= ampm ?A) (= hour 12))
                        (setq hour (% (+ hour 12) 24)))))))
 
@@ -1075,7 +1082,11 @@ as measured in the integer number of days before December 31, 1 BC (Gregorian)."
       (throw 'syntax "Day value is out of range"))
   (and hour
        (progn
-        (if (or (< hour 0) (> hour 23))
+        (if (or (< hour 0) 
+                 (> hour 24)
+                 (and (= hour 24)
+                      (not (= minute 0))
+                      (not (eq second 0))))
             (throw 'syntax "Hour value is out of range"))
         (if (or (< minute 0) (> minute 59))
             (throw 'syntax "Minute value is out of range"))
@@ -1091,7 +1102,11 @@ as measured in the integer number of days before December 31, 1 BC (Gregorian)."
       (throw 'syntax "Weekday value is out of range"))
   (and hour
        (progn
-        (if (or (< hour 0) (> hour 23))
+        (if (or (< hour 0) 
+                 (> hour 24)
+                 (and (= hour 24)
+                      (not (= minute 0))
+                      (not (eq second 0))))
             (throw 'syntax "Hour value is out of range"))
         (if (or (< minute 0) (> minute 59))
             (throw 'syntax "Minute value is out of range"))