Subject: issue with '/bin/date' resolving months via '-d DATESTR'

From: Benjamin Richardson <[email-masked]>
Date: Tue, 29 Apr 2014 16:17:48 -0400

Hello,

I think my issue can best be described by demonstration. Here goes:

user@server$ /bin/date
Tue Apr 29 15:51:11 EDT 2014
user@server$ /bin/date -d 'last month' +%B
March
user@server$ /bin/date -d '*2 months ago*' +%B
*March*
user@server$ /bin/date -d '3 months ago' +%B
January

I expected 2 months ago to be February, not March. I get that Feb 29
doesn't exist, so returning a date that never happened might not make
sense. But in simply asking for the month, not the full date of 2 months
ago, could %B be calculated first, before rolling over to March 1st?

Here is some other potentially helpful info:

user@server$ rpm -qf /bin/date
coreutils-5.97-34.el5_8.1
user@server$ date -d '1 month ago'
Sat Mar 29 15:57:36 EDT 2014
user@server$ date -d '2 months ago'
Sat Mar  1 14:57:45 EST 2014
user@server$ date -d '3 months ago'
Wed Jan 29 14:58:41 EST 2014

Thanks!
Ben