GNU bug report logs - #47476
relative date of -1 month shows the wrong month

Previous Next

Package: coreutils;

Reported by: Lars Noodén <lars.nooden <at> gmx.com>

Date: Mon, 29 Mar 2021 15:54:01 UTC

Severity: normal

Found in version 8.32-4

Full log


Message #8 received at 47476 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Lars Noodén <lars.nooden <at> gmx.com>, 47476 <at> debbugs.gnu.org
Subject: Re: bug#47476: relative date of -1 month shows the wrong month
Date: Mon, 29 Mar 2021 17:25:42 +0100
On 29/03/2021 16:39, Lars Noodén wrote:
> Severity: normal
> Package: coreutils
> Version: 8.32-4
> 
> On March 29, 2021, if a relative date of '-1 month' is passed to 'date',
> then the output shows March instead of February.
> 
> $ date; date -d '-1 month'; date -d '1 month ago'; date -d 'last month';
> Mon 29 Mar 2021 06:35:43 PM EEST
> Mon 01 Mar 2021 05:35:43 PM EET
> Mon 01 Mar 2021 05:35:43 PM EET
> Mon 01 Mar 2021 05:35:43 PM EET
> 
> The output shows March when it clearly should show February instead.
> This impairs the usefulness of the program a lot on certain days.

This is a commonly reported issue.
I agree the current operation is confusing.
I'm working on a change to make the adjustment relative to the input resolution.
I.e. operate on a month basis in this case rather than days etc.
The current FAQ (linked below) suggests the workaround of:

  date --date="$(date +%Y-%m-15) -1 month" +'Last month was %B.'

cheers,
Pádraig

https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e




This bug report was last modified 4 years and 75 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.