From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#21903: date->string duff ISO 8601 negative years Date: Sun, 21 Oct 2018 00:01:59 -0400 Message-ID: <87a7n80wy0.fsf@netris.org> References: <20151113140157.GN13455@fysh.org> <87lg6s2qpw.fsf@netris.org> <87sh10169x.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1540095434 29614 195.159.176.226 (21 Oct 2018 04:17:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 21 Oct 2018 04:17:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 21903-done@debbugs.gnu.org To: Zefram Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Oct 21 06:17:10 2018 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE5Ar-0007cZ-LC for guile-bugs@m.gmane.org; Sun, 21 Oct 2018 06:17:09 +0200 Original-Received: from localhost ([::1]:57421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gE5Cy-00081x-3U for guile-bugs@m.gmane.org; Sun, 21 Oct 2018 00:19:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gE5CV-0007az-RH for bug-guile@gnu.org; Sun, 21 Oct 2018 00:18:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gE4xC-0000du-8p for bug-guile@gnu.org; Sun, 21 Oct 2018 00:03:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:57688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gE4xC-0000dj-4M for bug-guile@gnu.org; Sun, 21 Oct 2018 00:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gE4xB-000533-Px for bug-guile@gnu.org; Sun, 21 Oct 2018 00:03:01 -0400 Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-To: bug-guile@gnu.org Resent-Date: Sun, 21 Oct 2018 04:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 21903 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Mail-Followup-To: 21903@debbugs.gnu.org, mhw@netris.org, zefram@fysh.org Original-Received: via spool by 21903-done@debbugs.gnu.org id=D21903.154009454119349 (code D ref 21903); Sun, 21 Oct 2018 04:03:01 +0000 Original-Received: (at 21903-done) by debbugs.gnu.org; 21 Oct 2018 04:02:21 +0000 Original-Received: from localhost ([127.0.0.1]:33711 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE4wW-000521-Uc for submit@debbugs.gnu.org; Sun, 21 Oct 2018 00:02:21 -0400 Original-Received: from world.peace.net ([64.112.178.59]:48820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE4wU-00051o-8E for 21903-done@debbugs.gnu.org; Sun, 21 Oct 2018 00:02:18 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gE4wO-0003lG-Dv; Sun, 21 Oct 2018 00:02:12 -0400 In-Reply-To: <87sh10169x.fsf@netris.org> (Mark H. Weaver's message of "Sat, 20 Oct 2018 20:40:26 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:9227 Archived-At: Mark H Weaver writes: > Mark H Weaver writes: > >> Zefram writes: >> >>> The date->string function from (srfi srfi-19), used on ISO 8601 formats >>> "~1", "~4" and "~5", for years preceding AD 1, has an off-by-one error: >>> >>> scheme@(guile-user)> (use-modules (srfi srfi-19)) >>> scheme@(guile-user)> (date->string (julian-day->date 0 0) "~4") >>> $1 = "-4714-11-24T12:00:00Z" >>> >>> The date in question, the JD epoch, is 24 November 4714 BC (in the >>> proleptic Gregorian calendar). In ISO 8601 format, that year is properly >>> represented as "-4713", not "-4714", because ISO 8601 uses the AD era >>> exclusively. 4714 BC = AD -4713. >> >> I agree that this is definitely a bug, but I'm nervous about deviating >> from the SRFI-19 reference implementation, and therefore probably from >> most other implementations of SRFI-19, in this way. > > Also see my comments here: > > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21904#17 > > which mention that ISO 8601 apparently requires that the sender and > receiver agree ahead of time whether an extended format will be used, in > which case a sign is *always* required, even when printing years in the > range 0-9999. Since writing this, I've discovered that the SRFI-19 reference implementation's formatting of negative years is very badly broken. For example, when the year is -2, it prints "00-2". Guile's behavior was similarly broken for a short time, after I applied upstream fixes. Since the current behavior of SRFI-19 and Guile is so clearly broken in the case of negative years, I'm no longer concerned with maintaining compatibility with SRFI-19 here. I also feel more urgency to apply a fix. So, I went ahead and implemented your recommended behavior, in commit a58c7abd72648f77e4ede5f62a2c4e7969bb7f95 on the stable-2.2 branch. I'm closing this bug now, but please reopen if appropriate. Thanks, Mark