Datetime.jl icon indicating copy to clipboard operation
Datetime.jl copied to clipboard

Adding negative months does not rollover year

Open msravi opened this issue 12 years ago • 3 comments

Hi,

Looks like adding -ve months doesn't rollover the year:

julia> using Datetime

julia> today() 2014-01-08

julia> today()+months(1) 2014-02-08

julia> today()+months(-1) 2014-12-08 *** Should return 2013-12-08 ***

*** The following work alright *** julia> today()+days(-1) 2014-01-07

julia> dt = date("2014-01-01") 2014-01-01

julia> dt+days(-1) 2013-12-31

julia> today()+years(-1) 2013-01-08

Hope this helps.

Regards, Ravi

msravi avatar Jan 08 '14 11:01 msravi

Similarly,

julia> date("2013-12-27")-months(-1) 2013-01-27

Regards, Ravi

msravi avatar Jan 08 '14 11:01 msravi

Thanks. Yeah, I found this as well as I was doing the rewrite to merge into Base. See JuliaLang/julia#5328. The examples above work on that code and I'll add some more tests for these.

quinnj avatar Jan 08 '14 21:01 quinnj

Fixed by ed8123ede2e316a181a781ecd54fd735657b6cd8

quinnj avatar Feb 28 '14 16:02 quinnj