[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26101: Counterproductive calculation order in date
From: |
Vincent Lefevre |
Subject: |
bug#26101: Counterproductive calculation order in date |
Date: |
Wed, 7 Feb 2018 01:37:34 +0100 |
User-agent: |
Mutt/1.9.3+89 (65e1f5c8) vl-105418 (2018-01-21) |
On 2017-03-15 13:23:48 +0100, Ulf Zibis wrote:
> A more simple example without touch:
> $ date +%F
> 2017-03-15
> $ date -d "-20 day" +%F
> 2017-02-23
> $ date -d "-20 day -2 month" +%F
> 2016-12-26
> $ date -d "-2 month -20 day" +%F
> 2016-12-26
>
> In the 2nd example I would expect:
> 2016-12-23
Similarly:
zira% date +%Y-%m-%d -d '2003-02-01 - 1 month'
2003-01-01
zira% date +%Y-%m-%d -d '2003-02-01 - 31 days'
2003-01-01
but if I add "+ 1 month", I get different results:
zira% date +%Y-%m-%d -d '2003-02-01 - 31 days + 1 month'
2003-01-29
zira% date +%Y-%m-%d -d '2003-02-01 - 1 month + 1 month'
2003-02-01
Unfortunately this behavior, which is due to the fact that operations
are reordered to take into account years, then months, then days, is
not documented in the Coreutils manual.
--
Vincent Lefèvre <address@hidden> - 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)
- bug#26101: Counterproductive calculation order in date,
Vincent Lefevre <=