emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/calendar/calendar.el,v


From: Glenn Morris
Subject: [Emacs-diffs] Changes to emacs/lisp/calendar/calendar.el,v
Date: Mon, 31 Mar 2008 15:59:30 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Glenn Morris <gm>       08/03/31 15:59:29

Index: calendar.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/calendar/calendar.el,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -b -r1.235 -r1.236
--- calendar.el 31 Mar 2008 07:10:20 -0000      1.235
+++ calendar.el 31 Mar 2008 15:59:29 -0000      1.236
@@ -1213,20 +1213,23 @@
 (defconst cal-hebrew-yahrzeit-buffer "*Yahrzeits*"
   "Name of the buffer used by `list-yahrzeit-dates'.")
 
-(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.
-This is only appropriate for calendars with 12 months per year."
-  `(let (macro-y)
-     ;; FIXME 12 could be an optional arg, if needed.
+Optional NMONTHS is the number of months per year (default 12)."
+  ;; Can view this as a form of base-nmonths arithmetic, in which "a
+  ;; year" = "ten", and we never bother to use hundreds.
+  `(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 12) ,mon -1 ,n)
-;;;            ,yr (/ macro-y 12)
-;;;            ,mon (- macro-y (* ,yr 12)))
+     (setq macro-y (+ (* ,yr nmonths) ,mon -1 ,n)
+           ,mon (1+ (mod macro-y nmonths))
+           ,yr (/ macro-y nmonths))
+     ;; Alternative:
+;;;      (setq macro-y (+ (* ,yr nmonths) ,mon -1 ,n)
+;;;            ,yr (/ macro-y nmonths)
+;;;            ,mon (- macro-y (* ,yr nmonths)))
      (and (< macro-y 0) (> ,mon 1) (setq ,yr (1- ,yr)))
      (if (< ,yr 1) (setq ,yr (1- ,yr))))) ; 0 AD -> -1 BC, etc
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]