GNU bug report logs -
#13071
Date and month ago
Previous Next
Reported by: Tuc at T-B-O-H <ml <at> t-b-o-h.net>
Date: Mon, 3 Dec 2012 20:41:02 UTC
Severity: normal
Tags: moreinfo, notabug
Done: Bob Proulx <bob <at> proulx.com>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
Running into a problem with date and month...
-------------------------------------------------------------------
#!/bin/bash
function example {
rptdate=$(date +%Y-%m-%d -d "$1 -6 months")
echo "6 months ago from $1 is ${rptdate}"
}
example 2012-09-30
example 2012-10-31
example 2012-10-30
example 2012-11-30
example 2012-12-01
example 2012-03-31
-------------------------------------------------------------------
6 months ago from 2012-09-30 is 2012-03-30
****6 months ago from 2012-10-31 is 2012-05-01***
6 months ago from 2012-10-30 is 2012-04-30
6 months ago from 2012-11-30 is 2012-05-30
6 months ago from 2012-12-01 is 2012-06-01
*****6 months ago from 2012-03-31 is 2011-10-01*
It seems that its running into the issue that if the 6 months ago doesn't
have the same amount of days, its falling into the next month. Is there a
way to tell it to instead just use the last day of the month?
Thanks, Tuc
This bug report was last modified 12 years and 230 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.