hroptatyr/dateutils — Issue #4: Problem with dadd, when input month is January and duration is -1y/-12m/etc.
Author: javajunkie314
Created: 2012-01-25 08:19:49+00:00
State: open

When I use dadd with a January date and subtract one year, the result is off by one year:

% dseq 2012-01-01 +1d 2012-01-31 | dadd -1y
2010-01-01
2010-01-02
2010-01-03
2010-01-04
2010-01-05
2010-01-06
2010-01-07
2010-01-08
2010-01-09
2010-01-10
2010-01-11
2010-01-12
2010-01-13
2010-01-14
2010-01-15
2010-01-16
2010-01-17
2010-01-18
2010-01-19
2010-01-20
2010-01-21
2010-01-22
2010-01-23
2010-01-24
2010-01-25
2010-01-26
2010-01-27
2010-01-28
2010-01-29
2010-01-30
2010-01-31

Every other month seems to be okay:

% dseq 2012-02-05 +1m 2012-12-05 | dadd -1y
2011-02-05
2011-03-05
2011-04-05
2011-05-05
2011-06-05
2011-07-05
2011-08-05
2011-09-05
2011-10-05
2011-11-05
2011-12-05

The problem persists with different starting years, and with the duration -12m.

% dadd 2012-01-25 -12m
2010-01-25
% dadd 1998-01-25 -12m
1996-01-25

Oddly, it does not occur with the duration -365d.

% dadd 2012-01-25 -365d
2011-01-25

I'm using dateutils 0.1.8 on Gentoo 3.2.1, installed from Portage.