On Mon, Jan 31, 2011 at 04:52:18AM -0000, Josh Kupershmidt wrote: > : > Feb. 30th is an invalid date which `date` doesn't want to return, which > is why it's bumping the result into March.
This explanation does not quite square with the behavior. Witness: date Mon Jan 31 08:51:30 EST 2011 date --date='this month' +%j 031 date --date='next month' +%j 062 date --date='next month' Thu Mar 3 08:57:01 EST 2011 So it _appears_ that the algorithm is next month -> +1 month month -> this month's number of days this month's number of days -> 31 Julian date += 31 I find it hard to accept that the given behavior is "correct" even if it is "as documented". So now the question becomes "am I motivated enough to dig into the code, understand it thoroughly enough to see what _is_ going on, and then do something about it." The simplest correct solution would seem to be: manipulations of "month" must take place as manipulations of the month field as expressed by the date format %m . _if_ the result is an illegal date ( i.e. 31 February ) _and_ the day of month ( %d ) or julian day ( %j ) will be output, _then_ output an illegal date error date --date='next month' date: invalid date `31 February' _else_ output date --date='next month' +%B February Would that be deemed acceptable behavior by the keepers of /bin/date ? -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/710368 Title: /bin/date --date='next month' is wrong -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs