diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2020-08-21 00:38:23 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2020-08-21 00:38:23 +0200 |
commit | cb9fc5e7731e506e4e0facd3d060d19e388b32ac (patch) | |
tree | dfe4e0d9258238d5cbd62c6c74383692b921a035 /lisp/calendar | |
parent | 9b277a2f8e5c22a05830e61d83876571b8eb56b4 (diff) | |
download | emacs-cb9fc5e7731e506e4e0facd3d060d19e388b32ac.tar.gz |
Fix off-by-one error in decoded-time-add (with months)
* lisp/calendar/time-date.el (decoded-time-add): Fix month
addition, which was off-by-one.
Diffstat (limited to 'lisp/calendar')
-rw-r--r-- | lisp/calendar/time-date.el | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index 125f9acc705..638d8c1f884 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el @@ -401,10 +401,10 @@ changes in daylight saving time are not taken into account." (when (decoded-time-year delta) (cl-incf (decoded-time-year time) (decoded-time-year delta))) - ;; Months are pretty simple. + ;; Months are pretty simple, but start at 1 (for January). (when (decoded-time-month delta) - (let ((new (+ (decoded-time-month time) (decoded-time-month delta)))) - (setf (decoded-time-month time) (mod new 12)) + (let ((new (+ (1- (decoded-time-month time)) (decoded-time-month delta)))) + (setf (decoded-time-month time) (1+ (mod new 12))) (cl-incf (decoded-time-year time) (/ new 12)))) ;; Adjust for month length (as described in the doc string). |