Mercurial > emacs
changeset 80716:5074702340f6
(increment-calendar-month): Optionally handle systems without 12
months per year (sync from trunk 2008-03-31; needed for above
holiday-bahai fix).
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sun, 10 Aug 2008 20:29:15 +0000 |
parents | 9c615a5917be |
children | 9a64a4d7dbe6 |
files | lisp/calendar/calendar.el |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/calendar/calendar.el Sun Aug 10 20:28:41 2008 +0000 +++ b/lisp/calendar/calendar.el Sun Aug 10 20:29:15 2008 +0000 @@ -1321,15 +1321,17 @@ (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