From debbugs-submit-bounces@debbugs.gnu.org Mon May 29 09:40:11 2023 Received: (at submit) by debbugs.gnu.org; 29 May 2023 13:40:11 +0000 Received: from localhost ([127.0.0.1]:57379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3d6V-0007WP-J0 for submit@debbugs.gnu.org; Mon, 29 May 2023 09:40:10 -0400 Received: from lists.gnu.org ([209.51.188.17]:58644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3bSz-0004nO-0r for submit@debbugs.gnu.org; Mon, 29 May 2023 07:55:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3bSx-0003ni-Rx for bug-coreutils@gnu.org; Mon, 29 May 2023 07:55:12 -0400 Received: from zimbra1.powercraft.nl ([185.40.94.90]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3bSv-0006fy-TW for bug-coreutils@gnu.org; Mon, 29 May 2023 07:55:11 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra1.powercraft.nl (Postfix) with ESMTP id 2EC80E01B1 for ; Mon, 29 May 2023 13:55:05 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra1.powercraft.nl Received: from zimbra1.powercraft.nl ([127.0.0.1]) by localhost (zimbra1.powercraft.nl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zW_V1ym41d-J for ; Mon, 29 May 2023 13:55:05 +0200 (CEST) Received: from yessica.powercraft.nl (unknown [192.168.26.1]) by zimbra1.powercraft.nl (Postfix) with ESMTPSA id 0C319E01A7 for ; Mon, 29 May 2023 13:55:05 +0200 (CEST) Received: from [192.168.24.120] (yoad.office.lan [192.168.24.120]) by yessica.powercraft.nl (Postfix) with ESMTPSA id D8EEB29174 for ; Mon, 29 May 2023 13:55:04 +0200 (CEST) Message-ID: Date: Mon, 29 May 2023 13:55:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 To: bug-coreutils@gnu.org Content-Language: nl-NL, en-GB From: Jelle de Jong Subject: date --date "1 month ago" +%Y-%m does not work as expected on day 31 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=185.40.94.90; envelope-from=jelledejong@powercraft.nl; helo=zimbra1.powercraft.nl X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 29 May 2023 09:40:05 -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: -2.3 (--) Hello everybody, I been hitting an issue for a while now that date commands return the wrong month on day 31 of a month and my automations stops working on correctly on these days. root@sydney:~# date Wed Aug 31 22:09:04 CEST 2022 root@sydney:~# date --date "1 month ago" +%Y-%m 2022-07 root@sydney:~# date --date "2 month ago" +%Y-%m 2022-07 root@sydney:~# date --date "3 month ago" +%Y-%m 2022-05 root@sydney:~# date --date "4 month ago" +%Y-%m 2022-05 root@sydney:~# date Sat Dec 31 19:20:13 CET 2022 root@sydney:~# date --date '1 month ago' +%Y-%m 2022-12 $ date --version date (GNU coreutils) 8.30 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later I would love to have this fixed if possible. If I am using the wrong command I would love to be educated as well. Should I use date --date "$(date +%Y-%m-01) -1 month" +%Y-%m instead... Kind regards, Jelle de Jong From debbugs-submit-bounces@debbugs.gnu.org Mon May 29 10:27:23 2023 Received: (at 63784) by debbugs.gnu.org; 29 May 2023 14:27:23 +0000 Received: from localhost ([127.0.0.1]:58689 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3dqF-0000m9-4S for submit@debbugs.gnu.org; Mon, 29 May 2023 10:27:23 -0400 Received: from mail-wm1-f50.google.com ([209.85.128.50]:60453) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q3dqD-0000ls-E5 for 63784@debbugs.gnu.org; Mon, 29 May 2023 10:27:21 -0400 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-3f6e13940daso35279845e9.0 for <63784@debbugs.gnu.org>; Mon, 29 May 2023 07:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685370435; x=1687962435; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=tTMzMwA6MQik5aLvcB1+Yyat3P8tJTIV/+9Rfu2sUaY=; b=FpP+BbupV3ZAeaOlYy6k4DdY+GfkkUi0WemP76l23tbA5tjPbRHb+mOzGEt4BqFXvT U4NYMaJ1ExKtFaDX5vO/Ux5qL953wnL9CeXzWULKO5D+4+KAD2U9PqK30d0mz1uBUiiL x0vaRMVv0/REkhZKAT9MMvkl1CcQ/piaqpgp0xWsnlGR3aTdIu4YauuSjw9IhGX+82qR WMQfnsrPbpwIlYBiQAmRYBEmmqXttsuy8eDPADGiCUfoqroEbSHDOEMT0TMR+urQMFmT sMz+kRs/l2UNJd8UcyfN4knsyB8PPV+o62ZSyFxQpjg9K2Kil5udbQ0Yy7/KwO+xlwVR If1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685370435; x=1687962435; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tTMzMwA6MQik5aLvcB1+Yyat3P8tJTIV/+9Rfu2sUaY=; b=II1M55lYew95m1FcoSo9UEjnS41ATNDWM97gq6Ti3TF0VJhQ2r8RtBRChbZqIIPqM/ 7kPN+Gznsa86YJSLcojFQT3UzCE7hV6vmaKC4tF4gogr1bUJmBc1jUNbhfD1IeMJcC4u FaNKz4rC9RyhE9bMgkibv1KikckBNHg/6NNNbUFmd5aO4Fb6okFzdbSZ4diVOp4fsdJC n0HuuFHw7WWrhObDus5yyuxxSwfkvVj40ymisjIN5jD1rzP2HsWLV5s7XiJtC7Fa5sY2 E+4FweShpmONH0D2pB1KamN3bnXT4BC5d3x289YJC5GUl30sa6s3ujqSIVwhNTw2EDot 295A== X-Gm-Message-State: AC+VfDwrTIcYcEIUJyBRUL/AJJSbF04OtMl024g43u5qfSri4vtdPcgW 64Te36QvJBJpbMq5pabLfH4oRXHvXfk= X-Google-Smtp-Source: ACHHUZ5bpdk8d+7xeKCbz8pKR6uflvBcJx6j5k0rqJ2sn5v9cBdHIDy4rvJcWzrFnMSFP2yAthOlhw== X-Received: by 2002:a05:600c:2055:b0:3f4:9bee:b9c with SMTP id p21-20020a05600c205500b003f49bee0b9cmr9366441wmg.18.1685370435204; Mon, 29 May 2023 07:27:15 -0700 (PDT) Received: from [192.168.1.19] (95-44-90-175-dynamic.agg2.lod.rsl-rtd.eircom.net. [95.44.90.175]) by smtp.googlemail.com with ESMTPSA id v7-20020a05600c214700b003f4f89bc48dsm18162361wml.15.2023.05.29.07.27.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 May 2023 07:27:14 -0700 (PDT) Message-ID: Date: Mon, 29 May 2023 15:27:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#63784: date --date "1 month ago" +%Y-%m does not work as expected on day 31 Content-Language: en-US To: Jelle de Jong , 63784@debbugs.gnu.org References: From: =?UTF-8?Q?P=C3=A1draig_Brady?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 63784 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: -0.8 (/) On 29/05/2023 12:55, Jelle de Jong wrote: > Hello everybody, > > I been hitting an issue for a while now that date commands return the > wrong month on day 31 of a month and my automations stops working on > correctly on these days. > > root@sydney:~# date > Wed Aug 31 22:09:04 CEST 2022 > root@sydney:~# date --date "1 month ago" +%Y-%m > 2022-07 > root@sydney:~# date --date "2 month ago" +%Y-%m > 2022-07 > root@sydney:~# date --date "3 month ago" +%Y-%m > 2022-05 > root@sydney:~# date --date "4 month ago" +%Y-%m > 2022-05 > > root@sydney:~# date > Sat Dec 31 19:20:13 CET 2022 > root@sydney:~# date --date '1 month ago' +%Y-%m > 2022-12 > > $ date --version > date (GNU coreutils) 8.30 > Copyright (C) 2018 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > > I would love to have this fixed if possible. > > If I am using the wrong command I would love to be educated as well. > Should I use date --date "$(date +%Y-%m-01) -1 month" +%Y-%m instead... Yes that is confusing. The current workaround is to operate relative to the middle of the month as described at: https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e