From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 15 03:11:34 2023 Received: (at submit) by debbugs.gnu.org; 15 Feb 2023 08:11:34 +0000 Received: from localhost ([127.0.0.1]:57660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pSCt4-0003L7-3e for submit@debbugs.gnu.org; Wed, 15 Feb 2023 03:11:34 -0500 Received: from lists.gnu.org ([209.51.188.17]:52884) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pS9SX-00060H-AI for submit@debbugs.gnu.org; Tue, 14 Feb 2023 23:31:57 -0500 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 1pS9SX-00054A-0i for bug-coreutils@gnu.org; Tue, 14 Feb 2023 23:31:57 -0500 Received: from mx1.mythic-beasts.com ([2a00:1098:0:86:1000:0:2:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pS9ST-00056Q-3m for bug-coreutils@gnu.org; Tue, 14 Feb 2023 23:31:56 -0500 Received: from [2a00:1098:86::12:1] (port=44718 helo=webmailb.vs.mythic-beasts.com) by mailhub-cam-d.mythic-beasts.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pS9SQ-00EoNJ-PN for bug-coreutils@gnu.org; Wed, 15 Feb 2023 04:31:50 +0000 Received: from localhost ([::1] helo=webmail.mythic-beasts.com) by webmailb.vs.mythic-beasts.com with esmtp (Exim 4.94.2) (envelope-from ) id 1pS9SL-00EEmT-8s for bug-coreutils@gnu.org; Wed, 15 Feb 2023 04:31:45 +0000 MIME-Version: 1.0 Date: Wed, 15 Feb 2023 04:31:45 +0000 From: Richard Neill To: bug-coreutils@gnu.org Subject: date doesn't parse negative years User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: rn214@richardneill.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1098:0:86:1000:0:2:1; envelope-from=rn214@richardneill.org; helo=mx1.mythic-beasts.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 15 Feb 2023 03:11:32 -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: -2.4 (--) Hello, I noticed that date doesn't accept negative years, such as in the date: -0001-01-02 (i.e. 2nd Jan 2 BC). It's also somewhat puzzling that even through date will convert a timestamp in that year to an output string, it won't parse that string as valid (i.e. the last 2 lines below). date +%Y-%m-%d -d '0001-01-02' -> 0001-01-02 date +%Y-%m-%d -d '0000-01-02' -> 0000-01-02 date +%Y-%m-%d -d '-0001-01-02' -> date: invalid date ‘-0001-01-02’ date +%Y-%m-%d -d @-62135510325 -> 0001-01-02 date +%Y-%m-%d -d @-62167132725 -> 0000-01-02 date +%Y-%m-%d -d @-62198668725 -> -001-01-02 date +%Y-%m-%d -d '-001-01-02' -> date: invalid date ‘-001-01-02’ My reading of ISO_8601 is that these are allowed in formats YYYY-MM-DD where YYYY is a 4-6 digit number which may be positive, zero or negative. https://en.wikipedia.org/wiki/ISO_8601 Note that we should treat year 0 is also 1 BC, while -1 AD is 2 BC. https://en.wikipedia.org/wiki/Year_zero Thanks very much. P.S. cal doesn't work with years 0 and below either.