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.
This commit is contained in:
Carsten Dominik 2009-01-06 23:32:16 +01:00
parent 9dc65e4811
commit e0bc2c7528
2 changed files with 7 additions and 1 deletions

View file

@ -1,5 +1,9 @@
2009-01-06 Carsten Dominik <carsten.dominik@gmail.com>
* 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.

View file

@ -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)