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 <[email protected]> - 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)
