Ihor Radchenko <[email protected]> writes:

> Morgan Smith <[email protected]> writes:
>
>> TLDR: I wrote a test suite for org habit.  See attached.
>
> Thanks!
> Two comments:
>
> 1. One of the tests is failing on my side:
>    FAILED  test-org-habit/following-days 

TLDR: This is a bug in org-habit.  Is there a robust way to add days to
a time object?


Oh how I do love time.  I mostly run the tests in containers on my
system.  But running this raw on my system does show the same test
failure.

This test takes place on "Sat Oct 17 00:00:00 2009".  Then in
`org-habit-insert-consistency-graphs' we run this snippet to add (in the
specific case of the test failure) 20 days:

`(time-add moment (days-to-time org-habit-following-days))'

This of course results in a date 20 days in the future of "Thu Nov 5
23:00:00 2009".  Wait that's not 20 days.  That's 19 days and 23 hours.
Oh dear.

Here is a snippet of ielm session in case you want to play with it a bit
yourself:

ELISP> (current-time-string 1255752000)
"Sat Oct 17 00:00:00 2009"

ELISP> (current-time-string (time-add 1255752000 (days-to-time 20)))
"Thu Nov  5 23:00:00 2009"


So I would like to ask: do we have a robust system for adding days to a
time object?  I do hope there is a function I'm overlooking.


I tried this but it didn't work:


ELISP> (current-time-string 
        (encode-time 
         (decoded-time-add
          (decode-time 1255752000)
          (make-decoded-time :day 20))))
"Thu Nov  5 23:00:00 2009"


I imagine the solution might be in calendar.el?

Reply via email to