aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-08-10 20:29:42 +0000
committerGlenn Morris2008-08-10 20:29:42 +0000
commit7b765ee622dace1bec3c627e459ab75e6461cdd7 (patch)
tree8c72638cd42e70b15654691b0ff5f18ff596aed3
parentf3f89619cfc36a44879501af536f537f3e9a4478 (diff)
downloademacs-7b765ee622dace1bec3c627e459ab75e6461cdd7.tar.gz
emacs-7b765ee622dace1bec3c627e459ab75e6461cdd7.zip
(increment-calendar-month): Optionally handle systems without 12
months per year (sync from trunk 2008-03-31; needed for above holiday-bahai fix).
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/calendar/calendar.el14
2 files changed, 12 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f23445c2bf2..57d81acbd6a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -34,6 +34,10 @@
34 (calendar-absolute-from-bahai): Fix the leap-year case (sync from trunk 34 (calendar-absolute-from-bahai): Fix the leap-year case (sync from trunk
35 2008-03-20). 35 2008-03-20).
36 36
37 * calendar/calendar.el (increment-calendar-month): Optionally handle
38 systems without 12 months per year (sync from trunk 2008-03-31; needed
39 for above holiday-bahai fix).
40
37 * calendar/cal-islam.el (holiday-islamic): Doc fix (sync from trunk 41 * calendar/cal-islam.el (holiday-islamic): Doc fix (sync from trunk
38 2008-04-23). 42 2008-04-23).
39 43
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index dae55bf1f8b..157af3f4030 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1321,15 +1321,17 @@ with descriptive strings such as
1321(defconst lunar-phases-buffer "*Phases of Moon*" 1321(defconst lunar-phases-buffer "*Phases of Moon*"
1322 "Name of the buffer used for the lunar phases.") 1322 "Name of the buffer used for the lunar phases.")
1323 1323
1324(defmacro increment-calendar-month (mon yr n) 1324(defmacro increment-calendar-month (mon yr n &optional nmonths)
1325 "Increment the variables MON and YR by N months. 1325 "Increment the variables MON and YR by N months.
1326Forward if N is positive or backward if N is negative. 1326Forward if N is positive or backward if N is negative.
1327A negative YR is interpreted as BC; -1 being 1 BC, and so on." 1327A negative YR is interpreted as BC; -1 being 1 BC, and so on.
1328 `(let (macro-y) 1328Optional NMONTHS is the number of months per year (default 12)."
1329 `(let ((nmonths (or ,nmonths 12))
1330 macro-y)
1329 (if (< ,yr 0) (setq ,yr (1+ ,yr))) ; -1 BC -> 0 AD, etc 1331 (if (< ,yr 0) (setq ,yr (1+ ,yr))) ; -1 BC -> 0 AD, etc
1330 (setq macro-y (+ (* ,yr 12) ,mon -1 ,n) 1332 (setq macro-y (+ (* ,yr nmonths) ,mon -1 ,n)
1331 ,mon (1+ (mod macro-y 12)) 1333 ,mon (1+ (mod macro-y nmonths))
1332 ,yr (/ macro-y 12)) 1334 ,yr (/ macro-y nmonths))
1333 (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr))) 1335 (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr)))
1334 (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc 1336 (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc
1335 1337