Re: policy around 'wontfix' bug tag
On 2018-02-05 09:39:12 -0500, Greg Wooledge wrote:
> (*) One specific shell script use case was "Get the last date of a given
> month." Now, obviously you can just set up an array of hard-coded month
> ending dates, and then write a function to determine whether the current
> year is a leap year for the February case. But if you want to do it with
> GNU date -d, then you have to guess a magic incantation that actually
> works. Usually by trial and error.
>
> Anyway, here's what I came up with:
>
> lastday() {
> date +%Y-%m-%d -d "$1 1 day ago + 1 month"
> }
But the exact meaning of "month" seems undocumented, which may
silently break in a future version (e.g. possibly as a consequence
of a bug fix). So this is a good example of what you should *not*
do.
This is completely crazy:
zira% date +%Y-%m-%d -d '2003-09-01 1 day ago + 1 month'
2003-09-30
zira% date +%Y-%m-%d -d '2003-09-01 1 day ago'
2003-08-31
zira% date +%Y-%m-%d -d '2003-08-31 + 1 month'
2003-10-01
So, while '2003-09-01 1 day ago' gives 2003-08-31, the following
are not equivalent:
* '2003-09-01 1 day ago + 1 month'
* '2003-08-31 + 1 month'
Where is the logic behind that?
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Reply to: