[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/calc/calc-forms.el,v
From: |
Jay Belanger |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/calc/calc-forms.el,v |
Date: |
Mon, 19 Mar 2007 03:16:21 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Jay Belanger <jpb> 07/03/19 03:16:20
Index: calc-forms.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calc/calc-forms.el,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- calc-forms.el 17 Mar 2007 17:41:19 -0000 1.19
+++ calc-forms.el 19 Mar 2007 03:16:20 -0000 1.20
@@ -727,8 +727,8 @@
(a nil) (b nil) (c nil) (bigyear nil) temp)
;; Extract the time, if any.
- (if (or (string-match
"\\([0-9][0-9]?\\):\\([0-9][0-9]?\\)\\(:\\([0-9][0-9]?\\(\\.[0-9]+\\)?\\)\\)?
*\\([ap]m?\\|[ap]\\. *m\\.\\|noon\\|n\\>\\|midnight\\|mid\\>\\|m\\>\\)?"
math-pd-str)
- (string-match "\\([0-9][0-9]?\\)\\(\\)\\(\\(\\(\\)\\)\\)
*\\([ap]m?\\|[ap]\\. *m\\.\\|noon\\|n\\>\\|midnight\\|mid\\>\\|m\\>\\)"
math-pd-str))
+ (if (or (string-match
"\\([0-9][0-9]?\\):\\([0-9][0-9]?\\)\\(:\\([0-9][0-9]?\\(\\.[0-9]+\\)?\\)\\)?
*\\([ap]\\>\\|[ap]m\\|[ap]\\.
*m\\.\\|noon\\|n\\>\\|midnight\\|mid\\>\\|m\\>\\)?" math-pd-str)
+ (string-match "\\([0-9][0-9]?\\)\\(\\)\\(\\(\\(\\)\\)\\)
*\\([ap]\\>\\|[ap]m\\|[ap]\\.
*m\\.\\|noon\\|n\\>\\|midnight\\|mid\\>\\|m\\>\\)" math-pd-str))
(let ((ampm (math-match-substring math-pd-str 6)))
(setq hour (string-to-number (math-match-substring math-pd-str
1))
minute (math-match-substring math-pd-str 2)
@@ -1313,7 +1313,19 @@
(defun math-std-daylight-savings (date dt zone bump)
"Standard North American daylight saving algorithm.
-This implements the rules for the U.S. and Canada as of 2007.
+Before 2007, this uses `math-std-daylight-savings-old', where
+daylight savings began on the first Sunday of April at 2 a.m.,
+and ended on the last Sunday of October at 2 a.m.
+As of 2007, this uses `math-std-daylight-savings-new', where
+daylight saving begins on the second Sunday of March at 2 a.m.,
+and ends on the first Sunday of November at 2 a.m."
+ (if (< (car dt) 2007)
+ (math-std-daylight-savings-old date dt zone bump)
+ (math-std-daylight-savings-new date dt zone bump)))
+
+(defun math-std-daylight-savings-new (date dt zone bump)
+ "Standard North American daylight saving algorithm as of 2007.
+This implements the rules for the U.S. and Canada.
Daylight saving begins on the second Sunday of March at 2 a.m.,
and ends on the first Sunday of November at 2 a.m."
(cond ((< (nth 1 dt) 3) 0)
@@ -1332,6 +1344,27 @@
(t 0))))
(t 0)))
+(defun math-std-daylight-savings-old (date dt zone bump)
+ "Standard North American daylight savings algorithm before 2007.
+This implements the rules for the U.S. and Canada.
+Daylight savings begins on the first Sunday of April at 2 a.m.,
+and ends on the last Sunday of October at 2 a.m."
+ (cond ((< (nth 1 dt) 4) 0)
+ ((= (nth 1 dt) 4)
+ (let ((sunday (math-prev-weekday-in-month date dt 7 0)))
+ (cond ((< (nth 2 dt) sunday) 0)
+ ((= (nth 2 dt) sunday)
+ (if (>= (nth 3 dt) (+ 3 bump)) -1 0))
+ (t -1))))
+ ((< (nth 1 dt) 10) -1)
+ ((= (nth 1 dt) 10)
+ (let ((sunday (math-prev-weekday-in-month date dt 31 0)))
+ (cond ((< (nth 2 dt) sunday) -1)
+ ((= (nth 2 dt) sunday)
+ (if (>= (nth 3 dt) (+ 2 bump)) 0 -1))
+ (t 0))))
+ (t 0)))
+
;;; Compute the day (1-31) of the WDAY (0-6) on or preceding the given
;;; day of the given month.
(defun math-prev-weekday-in-month (date dt day wday)
- [Emacs-diffs] Changes to emacs/lisp/calc/calc-forms.el,v, Glenn Morris, 2007/03/12
- [Emacs-diffs] Changes to emacs/lisp/calc/calc-forms.el,v, Chong Yidong, 2007/03/17
- [Emacs-diffs] Changes to emacs/lisp/calc/calc-forms.el,v,
Jay Belanger <=
- [Emacs-diffs] Changes to emacs/lisp/calc/calc-forms.el,v, Kim F. Storm, 2007/03/19
- [Emacs-diffs] Changes to emacs/lisp/calc/calc-forms.el,v, Glenn Morris, 2007/03/19