From unknown Sat Sep 13 02:39:37 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#38003 <38003@debbugs.gnu.org> To: bug#38003 <38003@debbugs.gnu.org> Subject: Status: date --date=-1month gives same month today Reply-To: bug#38003 <38003@debbugs.gnu.org> Date: Sat, 13 Sep 2025 09:39:37 +0000 retitle 38003 date --date=3D-1month gives same month today reassign 38003 coreutils submitter 38003 Ilja Honkonen severity 38003 normal tag 38003 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 10:34:38 2019 Received: (at submit) by debbugs.gnu.org; 31 Oct 2019 14:34:38 +0000 Received: from localhost ([127.0.0.1]:53982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQBX2-0007jy-Dm for submit@debbugs.gnu.org; Thu, 31 Oct 2019 10:34:36 -0400 Received: from lists.gnu.org ([209.51.188.17]:39665) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQ5uz-0007Yw-BX for submit@debbugs.gnu.org; Thu, 31 Oct 2019 04:34:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57555) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQ5uy-0003uU-5v for bug-coreutils@gnu.org; Thu, 31 Oct 2019 04:34:57 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQ5ux-00056B-4d for bug-coreutils@gnu.org; Thu, 31 Oct 2019 04:34:55 -0400 Received: from smtpvgate.fmi.fi ([193.166.223.36]:50172) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iQ5uw-000500-Pp for bug-coreutils@gnu.org; Thu, 31 Oct 2019 04:34:55 -0400 Received: from souk.fmi.fi (souk.fmi.fi [193.166.211.113]) (envelope-from ilja.honkonen@fmi.fi) by smtpVgate.fmi.fi (8.13.8/8.13.8/smtpgate-20190903/smtpVgate) with ESMTP id x9V8Yj9Q029826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 31 Oct 2019 10:34:45 +0200 Received: from [HIDDEN] by smtp.fmi.fi with ESMTP id x9V8Yj7Y021244 ; Thu, 31 Oct 2019 10:34:45 +0200 To: bug-coreutils@gnu.org From: Ilja Honkonen Subject: date --date=-1month gives same month today Message-ID: <165fc933-cd0b-861d-eba3-43284b78f140@fmi.fi> Date: Thu, 31 Oct 2019 10:34:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Filter: smtpVgate.fmi.fi: 1 received headers rewritten with id 20191031/18554/01 X-Filter: smtpVgate.fmi.fi: ID 18554/01, 1 parts scanned for known viruses X-Filter: souk.fmi.fi: ID 107329/01, 1 parts scanned for known viruses X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (smtpVgate.fmi.fi [193.166.223.36]); Thu, 31 Oct 2019 10:34:45 +0200 (EET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 193.166.223.36 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 31 Oct 2019 10:34:34 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hello 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 I assume using --date=-31day also wouldn't work if run e.g. in beginning of march so this looks like a bug. Same happens also without --utc and -I. Thanks Ilja From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 13:02:53 2019 Received: (at 38003) by debbugs.gnu.org; 31 Oct 2019 17:02:53 +0000 Received: from localhost ([127.0.0.1]:54178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQDqT-0003FC-Im for submit@debbugs.gnu.org; Thu, 31 Oct 2019 13:02:53 -0400 Received: from mail-wr1-f54.google.com ([209.85.221.54]:33081) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQDJt-0002KX-Oh for 38003@debbugs.gnu.org; Thu, 31 Oct 2019 12:29:13 -0400 Received: by mail-wr1-f54.google.com with SMTP id s1so6980227wro.0 for <38003@debbugs.gnu.org>; Thu, 31 Oct 2019 09:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dpG3uYeg3fRqPJwPxHXRkFiwq2cqzkISpnhtUI3ejY4=; b=iXwWWsGzAOv8T28hixf+R83HAysv//1EAb+NCXpdT9F2cEtw3DZn8wbSstNHY4Lhd0 Ho4jDnR/cMjuas8sI+jUCmiO397fF8OBDDriL6HimASlNaNz6xs1WdjuQwGJnohDw/hN 9U7IHA12pu/90lXmys4oHmKFTaG15ENdpHkY0Gj21MK/dTBpLMjDvzOPb/bdBNd5vVU8 1xAtrPDsC6vw14ADmKQGoK/t0cdIP7K3fqYFxv/zuS0Jlykd542qZUYytVTuNN/hw9ix Shb/9NyMojdjOGr/SBiczZpoBiS/TS6fONuLiMNom75EIMCc30Xf9bitU1Mj6VtuSKgJ 5nyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dpG3uYeg3fRqPJwPxHXRkFiwq2cqzkISpnhtUI3ejY4=; b=ruZNpNhJU5XsN0WjriQU6S3xPsPYPMZkTLlFBciFIDCTwDzU4scL8vCSwET6BG30Dy Dj7Dgdgpm2VL/mq7JNHTAma5yBa2S0xB7CxTjP4R1SOh5wGhBfh1sAOvg7ETb9jFrE0x 042dTJgMm74isgJdcjGImpiSiCD6e7r/JmV9DX5ZIzTC6rNTY80RSdIK1bqqn7ir69XC fWeNJ+1i5CT+CqK7k0jtXA4xpck5qvQ493eS5bxtprVGhcs1sbRK6UisKmlj1Qpb0u/n x2e2RXFHytWs1CeX+Xr3kVEpYBoN4E74yLLRedPsZIyxeraIGc+P/MAQBKpmWCWJwlpM s3OA== X-Gm-Message-State: APjAAAVjplrr5rby/kXOFobnC4brKW5W9z0bDZcQ0jwWI+pUKvs91F1b wi1fY1t5II4fqrJW5eqnc6RhxSnBdcy9VR5xG4E= X-Google-Smtp-Source: APXvYqxubkqHwq4Ck/UlNSoDNP78ovJCQat+R9URr2c9b0z888zVu8ZkMkixx1KvWl43/TIELLjgV0bv6S9yP8JeNI8= X-Received: by 2002:adf:f00d:: with SMTP id j13mr6085084wro.253.1572539341552; Thu, 31 Oct 2019 09:29:01 -0700 (PDT) MIME-Version: 1.0 References: <165fc933-cd0b-861d-eba3-43284b78f140@fmi.fi> In-Reply-To: <165fc933-cd0b-861d-eba3-43284b78f140@fmi.fi> From: Steven Hilton Date: Thu, 31 Oct 2019 17:25:53 +0100 Message-ID: Subject: Re: bug#38003: date --date=-1month gives same month today To: Ilja Honkonen Content-Type: multipart/alternative; boundary="000000000000d93e66059637580f" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38003 X-Mailman-Approved-At: Thu, 31 Oct 2019 13:02:48 -0400 Cc: 38003@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000d93e66059637580f Content-Type: text/plain; charset="UTF-8" There will be a discontinuity as long as the months are different lengths. In the current implementation there will be only one discontinuity per month; the 1st of the month always goes back to the 1st of the preceding month. The overlap into the next month continues linearly until "now" is the 1st of the month. If I understand correctly, you would prefer that on March 29th, 30th, and 31st, this command would return the same date (except on leap years)? $ date --date=-1month +"%m-%d" 02-28 This would introduce one to three discontinuities per month, but the calculated month difference always the preceding month. On Thu, Oct 31, 2019 at 3:46 PM Ilja Honkonen wrote: > Hello > 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 > I assume using --date=-31day also wouldn't work if run e.g. in beginning > of march so this looks like a bug. Same happens also without --utc and > -I. Thanks > Ilja > > > > --000000000000d93e66059637580f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
There will be a discontinuity=C2=A0as long as the mon= ths are different lengths.

In the current implemen= tation there will be only one discontinuity per month; the 1st of the month= always=C2=A0goes back to the 1st of the preceding month. The overlap into = the next month continues linearly until "now" is the 1st of the m= onth.

If I understand correctly, you would prefer = that on March 29th, 30th, and 31st, this command would return the same date= (except on leap years)?
$ date --date=3D-1month=C2=A0+"%m-%= d"
02-28=C2=A0
This would introduce one to three disc= ontinuities per month, but the calculated month difference always the prece= ding month.


On Thu, Oct 31, 2019 at 3:46 PM Ilja Honkon= en <ilja.honkonen@fmi.fi>= wrote:
Hello Please CC me as I'm not on this list. Running date (GNU coreutils) 8.26=
on fedora 30 today (date --utc=C2=A0 -I: 2019-10-31) with --date=3D-1month = gives
the same month which doesn't make sense:
$ date --utc -I --date=3D-1month
2019-10-01
I assume using --date=3D-31day also wouldn't work if run e.g. in beginn= ing
of march so this looks like a bug. Same happens also without --utc and
-I. Thanks
Ilja



--000000000000d93e66059637580f-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 13:35:56 2019 Received: (at 38003) by debbugs.gnu.org; 31 Oct 2019 17:35:56 +0000 Received: from localhost ([127.0.0.1]:54238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQEMW-00087X-B9 for submit@debbugs.gnu.org; Thu, 31 Oct 2019 13:35:56 -0400 Received: from mail-pg1-f171.google.com ([209.85.215.171]:42703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iQEMU-00087D-IQ; Thu, 31 Oct 2019 13:35:55 -0400 Received: by mail-pg1-f171.google.com with SMTP id s23so1105125pgo.9; Thu, 31 Oct 2019 10:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=KG8A655jgcYueRL42BZwmqGf/8FfVMkeZoH53UlKjdY=; b=P6qBv6fSdO4xWsRpIb+zNXXwKucVDQnq8auBxX0ZpmIgwqpViOyTSsTlgsp7Ngnl5Z 5KX+LmL4pNpGoaK+/JkQPqm180sfoz8HDVKfm7W0BBjNze2jY3RwDoNVzot0LJHXR/Dm KbUEh3oy4SRxGlIhaDLIEe9yi6M2MZNmcz73hYOZ7uWd56sWsAqqlYoTlICa/zK+ZSeE N55DRUKlMpm9xwfKb0vNDwRij3gR5TPmrnkuA8YOkiAhg8o8VjkmAkC0ilgRsMLIRlWA EaROnFcu/HololxpBCHQ0PxXGg0Z23VNHl1m/l/Qw0SGUfrVWwDfGEQWpXxvgRia56W3 /hUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KG8A655jgcYueRL42BZwmqGf/8FfVMkeZoH53UlKjdY=; b=VlOIDTwm6fiuuUqr3btdg3Xib36DHtbkUKeznKhZlR7gmWw2A70Wk++1TKL7ixGq5h 0TAGVo1lWxHRly0Nz/hQLRlJnyf9qfLLTU8xv9daGFJc/QY2VnWJfrPP3gF0aR+mQksH rXxK7fJOKVnPqFairNqv7eVjROdlR/IQjDNDP3e8UVNLjtFvEz76rGwatu2T5tC1Luoz qSJyhRvyeHExdJJguxb2gw/0nM/LdWS1LV3TSK82lTP7F1Ap6wAR9cqaaznaLN2DfOXN 9TSRx1PoCYJlKB6fuZfc5Oci7p+x6jPaGBZ2nGFxYe/KWygbhe3C4cPZmKcUDuJI/WPv HkEQ== X-Gm-Message-State: APjAAAXGlwXSnEIuqCNVk9+Rz1nNlGTRnFQTScwArxdYAeN5vRrpZc/y 8v3RMSZaTEtqVWI1jOSF2Ma5NtL0 X-Google-Smtp-Source: APXvYqzTztlga6ILmXAnTJaB219fayX4T2FCn4KjR9Mly4Zws2k/lH0I04E1prL7kvVhJFVI4WiAqw== X-Received: by 2002:a63:4819:: with SMTP id v25mr2663757pga.165.1572543348116; Thu, 31 Oct 2019 10:35:48 -0700 (PDT) Received: from tomato.moose.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id y24sm5835281pfr.116.2019.10.31.10.35.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 31 Oct 2019 10:35:47 -0700 (PDT) Subject: Re: bug#38003: date --date=-1month gives same month today To: Ilja Honkonen , 38003@debbugs.gnu.org References: <165fc933-cd0b-861d-eba3-43284b78f140@fmi.fi> From: Assaf Gordon Message-ID: Date: Thu, 31 Oct 2019 11:35:46 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <165fc933-cd0b-861d-eba3-43284b78f140@fmi.fi> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38003 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 06 10:15:52 2019 Received: (at 38003) by debbugs.gnu.org; 6 Nov 2019 15:15:52 +0000 Received: from localhost ([127.0.0.1]:41043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iSN2F-0000dN-Da for submit@debbugs.gnu.org; Wed, 06 Nov 2019 10:15:52 -0500 Received: from smtpvgate.fmi.fi ([193.166.223.36]:33280) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iSLw5-0004rd-5U for 38003@debbugs.gnu.org; Wed, 06 Nov 2019 09:05:26 -0500 Received: from souk.fmi.fi (souk.fmi.fi [193.166.211.113]) (envelope-from ilja.honkonen@fmi.fi) by smtpVgate.fmi.fi (8.13.8/8.13.8/smtpgate-20190903/smtpVgate) with ESMTP id xA6E5HI4003394 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Nov 2019 16:05:17 +0200 Received: from [HIDDEN] by smtp.fmi.fi with ESMTP id xA6E5H8l014121 ; Wed, 6 Nov 2019 16:05:17 +0200 Subject: Re: bug#38003: date --date=-1month gives same month today To: Assaf Gordon , 38003@debbugs.gnu.org References: <165fc933-cd0b-861d-eba3-43284b78f140@fmi.fi> From: Ilja Honkonen Message-ID: Date: Wed, 6 Nov 2019 16:05:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Filter: smtpVgate.fmi.fi: 1 received headers rewritten with id 20191106/14625/01 X-Filter: smtpVgate.fmi.fi: ID 14625/01, 1 parts scanned for known viruses X-Filter: souk.fmi.fi: ID 158945/01, 1 parts scanned for known viruses X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (smtpVgate.fmi.fi [193.166.223.36]); Wed, 06 Nov 2019 16:05:17 +0200 (EET) X-Spam-Flag: NO X-Spam-Status: False, hits=-1.9 required=5 (smtpVgate.fmi.fi: ID 14625/01) report=BAYES_00,T_RP_MATCHES_RCVD X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38003 X-Mailman-Approved-At: Wed, 06 Nov 2019 10:15:50 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > 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. Thanks for explanation. To me it makes more sense that going one month back from 31 oct, or last day of oct, would give last day of sep instead of first day of oct. But now that I'm aware of this feature I can work around it if needed. Ilja From unknown Sat Sep 13 02:39:37 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 05 Dec 2019 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator