tag 38003 notabug
close 38003
stop

Hello,

On 2019-10-31 2:34 a.m., Ilja Honkonen wrote:
Please CC me as I'm not on this list. Running date (GNU coreutils) 8.26 on fedora 30 today (date --utc  -I: 2019-10-31) with --date=-1month gives the same month which doesn't make sense:
$ date --utc -I --date=-1month
2019-10-01

date gained a "--debug" option that helps diagnosing the issue:

$ date --utc -I --debug --date=-1month
date: parsed relative part: -1 month(s)
[...]
date: using current date as starting value: '(Y-M-D) 2019-10-31'
[...]
date: warning: when adding relative months/years, it is recommended to specify the 15th of the months <----
date: after date adjustment (+0 years, -1 months, +0 days),
date:     new date/time = '(Y-M-D) 2019-10-01 17:29:20'
date: warning: month/year adjustment resulted in shifted dates:
date:      adjusted Y M D: 2019 09 31    <----
date:    normalized Y M D: 2019 10 01    <----
[...]
date: final: (Y-M-D) 2019-10-01 17:29:20 (UTC)
2019-10-01

------

Subtracting 1 month from October 31st results in September 31st.
Since the date doesn't exist, it is normalized:
September 31st is "one day after September 30th", which
results in October 1st.

The "--debug" option also warns: when subtracting months,
it is recommended to specify the 15th (middle) of the month,
exactly to avoid such issues.

   $ date --utc -I --date="2019-10-15 -1month"
   2019-09-15

regards,
 - assaf




Reply via email to