From e0bc2c7528b6b325caaf291bb6ebecb5877f099c Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jan 2009 23:32:16 +0100 Subject: [PATCH] Bugfix: Deadlines with yearly repeat. Bernt Hansen writes: I've been bad and let a couple of my overhead tasks slip past their deadline dates. *** TODO Q1 Accounting: October DEADLINE: <2008-11-30 Mon +1y> - CLOSING NOTE [2008-01-30 Wed 12:18] This task does not show up on my agenda anymore (probably because the year changed). If I change the deadline entry to this: DEADLINE: <2008-11-30 Mon> then it shows up as 37 days late. I'm bringing this up as soon as I noticed it just so people are aware of this. I have a few of these tasks that just dropped off my agenda (probably at the beginning of the year). This interesting bug seems only to happen when the repeat is yearly, and after crossing the December 31st year boundary. It was a sorting issue - Org-mode (in the function `org-closest-date') computes two dates that are consistent with the repeater, one before and one after the target date. When the computation is done with a preference for the past date (as it happens for deadlines), it should use the earlier date. In fact, it did choose "n1", assuming that it was the earlier one. This assumption does hold for daily, weekly and monthly repeaters, but not for yearly ones. This commits make sure that "n1" always holds the earlier date, so that the logic at the end of the function works again. --- lisp/ChangeLog | 4 ++++ lisp/org.el | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index aa5d6c8a2..d1c086c62 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2009-01-06 Carsten Dominik + * org.el (org-closest-date): Fix bug with yearly repeats, in + combination with preference of the past as it is used for deadline + and scheduling search. + * org-exp.el (org-html-handle-time-stamps): No longer check for the `org-export-with-timestamps' option, because the preprocesser has taken care of this already. diff --git a/lisp/org.el b/lisp/org.el index 478d7b38f..103d403fe 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11633,7 +11633,7 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp." ;; Make the proper lists from the dates (catch 'exit (let ((a1 '(("d" . day) ("w" . week) ("m" . month) ("y" . year))) - dn dw sday cday n1 n2 + dn dw sday cday n1 n2 n0 d m y y1 y2 date1 date2 nmonths nm ny m2) (setq start (org-date-to-gregorian start) @@ -11682,6 +11682,8 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp." (setq m2 (+ m dn) y2 y) (if (> m2 12) (setq y2 (1+ y2) m2 (- m2 12))) (setq n2 (calendar-absolute-from-gregorian (list m2 d y2)))))) + ;; Make sure n1 is the earlier date + (setq n0 n1 n1 (min n1 n2) n2 (max n0 n2)) (if show-all (cond ((eq prefer 'past) n1) -- 2.11.4.GIT