From: Glenn Morris Date: Sun, 10 Aug 2008 20:29:42 +0000 (+0000) Subject: (increment-calendar-month): Optionally handle systems without 12 X-Git-Tag: emacs-pretest-22.2.90~7 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7b765ee622dace1bec3c627e459ab75e6461cdd7;p=emacs.git (increment-calendar-month): Optionally handle systems without 12 months per year (sync from trunk 2008-03-31; needed for above holiday-bahai fix). --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f23445c2bf2..57d81acbd6a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -34,6 +34,10 @@ (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). 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 (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