]> code.delx.au - gnu-emacs/commitdiff
(increment-calendar-month): Optionally handle systems without 12
authorGlenn Morris <rgm@gnu.org>
Sun, 10 Aug 2008 20:29:42 +0000 (20:29 +0000)
committerGlenn Morris <rgm@gnu.org>
Sun, 10 Aug 2008 20:29:42 +0000 (20:29 +0000)
months per year (sync from trunk 2008-03-31; needed for above
holiday-bahai fix).

lisp/ChangeLog
lisp/calendar/calendar.el

index f23445c2bf2cc9636e53fd2e93d97803f0fb4999..57d81acbd6aca69f4289d7662ff426e6888cc80b 100644 (file)
        (calendar-absolute-from-bahai): Fix the leap-year case (sync from trunk
        2008-03-20).
 
+       * calendar/calendar.el (increment-calendar-month): Optionally handle
+       systems without 12 months per year (sync from trunk 2008-03-31; needed
+       for above holiday-bahai fix).
+
        * calendar/cal-islam.el (holiday-islamic): Doc fix (sync from trunk
        2008-04-23).
 
index dae55bf1f8b08d9ef1d3f62fb4f615b73a4d64fe..157af3f40300269871ae5ae6f4d1199def73741d 100644 (file)
@@ -1321,15 +1321,17 @@ with descriptive strings such as
 (defconst lunar-phases-buffer "*Phases of Moon*"
   "Name of the buffer used for the lunar phases.")
 
-(defmacro increment-calendar-month (mon yr n)
+(defmacro increment-calendar-month (mon yr n &optional nmonths)
   "Increment the variables MON and YR by N months.
 Forward if N is positive or backward if N is negative.
-A negative YR is interpreted as BC; -1 being 1 BC, and so on."
-  `(let (macro-y)
+A negative YR is interpreted as BC; -1 being 1 BC, and so on.
+Optional NMONTHS is the number of months per year (default 12)."
+  `(let ((nmonths (or ,nmonths 12))
+         macro-y)
      (if (< ,yr 0) (setq ,yr (1+ ,yr))) ; -1 BC -> 0 AD, etc
-     (setq macro-y (+ (* ,yr 12) ,mon -1 ,n)
-           ,mon (1+ (mod macro-y 12))
-           ,yr (/ macro-y 12))
+     (setq macro-y (+ (* ,yr nmonths) ,mon -1 ,n)
+           ,mon (1+ (mod macro-y nmonths))
+           ,yr (/ macro-y nmonths))
      (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr)))
      (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc