X-Loop: help-debbugs@HIDDEN Subject: bug#21904: date->string duff ISO 8601 format for non-4-digit years Resent-From: Zefram <zefram@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Fri, 13 Nov 2015 14:23:01 +0000 Resent-Message-ID: <handler.21904.B.14474245629328 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 21904 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 21904 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-guile@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.14474245629328 (code B ref -1); Fri, 13 Nov 2015 14:23:01 +0000 Received: (at submit) by debbugs.gnu.org; 13 Nov 2015 14:22:42 +0000 Received: from localhost ([127.0.0.1]:36826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1ZxFFR-0002QM-QG for submit <at> debbugs.gnu.org; Fri, 13 Nov 2015 09:22:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48575) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from <zefram@HIDDEN>) id 1ZxFFP-0002QE-BG for submit <at> debbugs.gnu.org; Fri, 13 Nov 2015 09:22:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1ZxFFO-0003QE-HR for submit <at> debbugs.gnu.org; Fri, 13 Nov 2015 09:22:39 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:35567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1ZxFFO-0003QA-EK for submit <at> debbugs.gnu.org; Fri, 13 Nov 2015 09:22:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1ZxFFK-0002dm-3j for bug-guile@HIDDEN; Fri, 13 Nov 2015 09:22:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1ZxFFJ-0003OY-5b for bug-guile@HIDDEN; Fri, 13 Nov 2015 09:22:34 -0500 Received: from river6.fysh.org ([2001:41d0:d:20da::2]:37484 helo=river.fysh.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <zefram@HIDDEN>) id 1ZxFFI-0003ON-Vk for bug-guile@HIDDEN; Fri, 13 Nov 2015 09:22:33 -0500 Received: from zefram by river.fysh.org with local (Exim 4.80 #2 (Debian)) id 1ZxFFF-0001HK-Hr; Fri, 13 Nov 2015 14:22:29 +0000 Date: Fri, 13 Nov 2015 14:22:29 +0000 From: Zefram <zefram@HIDDEN> Message-ID: <20151113142229.GO13455@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.0 (----) The date->string function from (srfi srfi-19), used on ISO 8601 formats "~1", "~4", and "~5", gets the formatting of year numbers wrong when the year number doesn't have exactly four digits. There are multiple cases: scheme@(guile-user)> (date->string (julian-day->date 1500000 0) "~1") $1 = "-607-10-04" scheme@(guile-user)> (date->string (julian-day->date 1700000 0) "~1") $2 = "-59-05-05" scheme@(guile-user)> (date->string (julian-day->date 1720000 0) "~1") $3 = "-4-02-05" For year numbers -999 to -1 inclusive, date->string is using the minimum number of digits to express the number, but ISO 8601 requires the use of at least four digits, with zero padding on the left. So one should write "-0059" rather than "-59", for example. Note that this range is also affected by the off-by-one error in the selection of the year number that I described in bug #21903, but that's not the subject of the present bug report. Here I'm concerned with how the number is represented in characters, not with how the year is represented numerically. scheme@(guile-user)> (date->string (julian-day->date 1722000 0) "~1") $4 = "2-07-29" scheme@(guile-user)> (date->string (julian-day->date 1730000 0) "~1") $5 = "24-06-23" scheme@(guile-user)> (date->string (julian-day->date 2000000 0) "~1") $6 = "763-09-18" For year numbers 1 to 999 inclusive, again date->string is using the minimum number of digits to express the number, but ISO 8601 requires the use of at least four digits. If no leading "+" sign is used then the number must be exactly four digits, and that is the appropriate format to use in this situation. So one should write "0024" rather than "24", for example. The year number 0, representing the year 1 BC, logically also falls into this group, and should be represented textually as "0000". Currently this case doesn't arise in the function's output, because the off-by-one bug has it erroneously emit "-1" for that year. scheme@(guile-user)> (date->string (julian-day->date 10000000 0) "~1") $7 = "22666-12-20" scheme@(guile-user)> (date->string (julian-day->date 100000000 0) "~1") $8 = "269078-08-07" For year numbers 10000 and above, it is necessary to use more than four digits for the year, and that's permitted, but ISO 8601 requires that more than four digits are preceded by a sign. For positive year numbers the sign must be "+". So one should write "+22666" rather than "22666", for example. The formatting of year numbers for ISO 8601 purposes is currently only correct for numbers -1000 and lower (though the choice of number is off by one) and for year numbers 1000 to 9999 inclusive. -zefram
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Zefram <zefram@HIDDEN> Subject: bug#21904: Acknowledgement (date->string duff ISO 8601 format for non-4-digit years) Message-ID: <handler.21904.B.14474245629328.ack <at> debbugs.gnu.org> References: <20151113142229.GO13455@HIDDEN> X-Gnu-PR-Message: ack 21904 X-Gnu-PR-Package: guile Reply-To: 21904 <at> debbugs.gnu.org Date: Fri, 13 Nov 2015 14:23:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-guile@HIDDEN If you wish to submit further information on this problem, please send it to 21904 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 21904: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21904 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#21904: date->string duff ISO 8601 format for non-4-digit years Resent-From: Zefram <zefram@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Thu, 20 Apr 2017 00:05:01 +0000 Resent-Message-ID: <handler.21904.B21904.149264668210129 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 21904 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 21904 <at> debbugs.gnu.org Received: via spool by 21904-submit <at> debbugs.gnu.org id=B21904.149264668210129 (code B ref 21904); Thu, 20 Apr 2017 00:05:01 +0000 Received: (at 21904) by debbugs.gnu.org; 20 Apr 2017 00:04:42 +0000 Received: from localhost ([127.0.0.1]:57643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1d0zaU-0002dJ-CB for submit <at> debbugs.gnu.org; Wed, 19 Apr 2017 20:04:42 -0400 Received: from river.fysh.org ([87.98.248.19]:43654 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <zefram@HIDDEN>) id 1d0zaS-0002dA-2F for 21904 <at> debbugs.gnu.org; Wed, 19 Apr 2017 20:04:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fysh.org; s=20170316; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date; bh=OnhXMlbbBpKEqIOyyuu1o+P5n8ntsgZAzfdQJa5Wglo=; b=mZGOSZWUDx60UjJ3JPyo7YnrufV+1h7wO6xTd2LNpCJFdDd5wy4rPB3fzzoIjoEQtnPOmlS/U6AkLhsUoQhQwkC6/tvnFy6V5PLZ9WJ6OG24t5YuRMemJLCSkWMjA1CwgaSDAMUPNN4ca+S/X86BsMb/besrtA3MjrNuZgzgrR4=; Received: from zefram by river.fysh.org with local (Exim 4.84_2 #1 (Debian)) id 1d0zaP-0005jD-Hd; Thu, 20 Apr 2017 01:04:37 +0100 Date: Thu, 20 Apr 2017 01:04:37 +0100 From: Zefram <zefram@HIDDEN> Message-ID: <20170420000437.GD912@HIDDEN> References: <20151113142229.GO13455@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="wxDdMuZNg1r63Hyj" Content-Disposition: inline In-Reply-To: <20151113142229.GO13455@HIDDEN> X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.0 (/) --wxDdMuZNg1r63Hyj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline A patch to fix this is attached. The ISO 8601 date formats were implemented by using the ~Y formatter for the year portion, but SRFI-19 doesn't require ~Y to follow ISO 8601, so this raises the question of whether ~Y should. It could be fixed by changing ~Y to conform to ISO 8601, retaining the existing factoring of the formatters. Or a separate internal formatting function could be instituted to do ISO 8601 year formatting, with ~1 et al using that and ~Y left unchanged. I chose the former strategy, partly because the funny non-linear year number doesn't seem a useful thing to support in date->string at all, but more strongly because it's useful to have access to ISO 8601 year formatting on its own. There isn't any other format specifier for that job; it looks like SRFI-19 imagines that ~Y will fill that need. -zefram --wxDdMuZNg1r63Hyj Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-fix-SRFI-19-s-ISO-8601-year-syntax.patch" From 43dfb5fabc9debb80f87b17d82a1adde356e547c Mon Sep 17 00:00:00 2001 From: Zefram <zefram@HIDDEN> Date: Thu, 20 Apr 2017 00:42:54 +0100 Subject: [PATCH 1/2] fix SRFI-19's ISO 8601 year syntax The ISO 8601 date formats offered by SRFI-19's date->string function were emitting incorrect syntax for most years. At least four digits of year must be given, but it wasn't padding shorter numbers. And any number with more than four digits requires a leading sign, but this was being omitted for positive numbers. These problems are now fixed. The ISO 8601 date formats were formerly implemented in terms of the ~Y format, which was not specified to be an ISO 8601 format. The fix is achieved by altering ~Y to behave in the ISO 8601 manner, and ~Y is now documented to conform to ISO 8601. Doing it this way means that ISO 8601 year numbering is available in isolation, which is a useful facility not otherwise available. --- doc/ref/srfi-modules.texi | 1 + module/srfi/srfi-19.scm | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index da7850f..8a5f1a0 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -2815,6 +2815,7 @@ with locale decimal point, eg.@: @samp{5.2} @item @nicode{~y} @tab year, two digits, @samp{00} to @samp{99} @item @nicode{~Y} @tab year, full, eg.@: @samp{2003} +(in ISO 8601 format, though SRFI-19 doesn't specify so) @item @nicode{~z} @tab time zone, RFC-822 style @item @nicode{~Z} @tab time zone symbol (not currently implemented) @item @nicode{~1} @tab ISO-8601 date, @samp{~Y-~m-~d} diff --git a/module/srfi/srfi-19.scm b/module/srfi/srfi-19.scm index 4b8445f..d4308bb 100644 --- a/module/srfi/srfi-19.scm +++ b/module/srfi/srfi-19.scm @@ -1128,7 +1128,10 @@ 2) port))) (cons #\Y (lambda (date pad-with port) - (display (date-year date) port))) + (let ((y (date-year date))) + (cond ((negative? y) (display #\- port)) + ((>= y 10000) (display #\+ port))) + (display (padding (abs y) #\0 4) port)))) (cons #\z (lambda (date pad-with port) (rfc-822-tz-print (date-zone-offset date) port))) (cons #\Z (lambda (date pad-with port) -- 2.1.4 --wxDdMuZNg1r63Hyj--
X-Loop: help-debbugs@HIDDEN Subject: bug#21904: date->string duff ISO 8601 format for non-4-digit years Resent-From: Zefram <zefram@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Thu, 20 Apr 2017 00:08:02 +0000 Resent-Message-ID: <handler.21904.B21904.149264682610369 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 21904 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 21904 <at> debbugs.gnu.org Received: via spool by 21904-submit <at> debbugs.gnu.org id=B21904.149264682610369 (code B ref 21904); Thu, 20 Apr 2017 00:08:02 +0000 Received: (at 21904) by debbugs.gnu.org; 20 Apr 2017 00:07:06 +0000 Received: from localhost ([127.0.0.1]:57647 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1d0zcn-0002hB-SP for submit <at> debbugs.gnu.org; Wed, 19 Apr 2017 20:07:06 -0400 Received: from river.fysh.org ([87.98.248.19]:42537 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <zefram@HIDDEN>) id 1d0zcm-0002h4-TQ for 21904 <at> debbugs.gnu.org; Wed, 19 Apr 2017 20:07:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fysh.org; s=20170316; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date; bh=xvqNqYbsRZEUFCaXYqp5W2EtmAckeOe1YHRJyE0+Kes=; b=xP/sWIzQCINS+JNEZVoV0ciuymQ7xoJ/84GDrjGnOBL36+qCYnmojFfysjHtt7Wcngj5m9I5/3gKVoHRPQJYzOtr9gE4i0Zbuded7n6LFAjUMVzQOX+n5Q5LWSuMWM20Q6deE86J4WP1veMUfDoYdbLhcZ41Se2+M3fjhAJVONg=; Received: from zefram by river.fysh.org with local (Exim 4.84_2 #1 (Debian)) id 1d0zck-0005pi-OR; Thu, 20 Apr 2017 01:07:02 +0100 Date: Thu, 20 Apr 2017 01:07:02 +0100 From: Zefram <zefram@HIDDEN> Message-ID: <20170420000702.GF6765@HIDDEN> References: <20151113142229.GO13455@HIDDEN> <20170420000437.GD912@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170420000437.GD912@HIDDEN> X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.0 (/) I wrote: >I chose the former strategy, partly because the funny non-linear year >number doesn't seem a useful thing to support in date->string at all, Sorry, this comment is misplaced. It relates to bug#21903; the choice about ~Y applies to both of these bugs. -zefram
X-Loop: help-debbugs@HIDDEN Subject: bug#21904: date->string duff ISO 8601 format for non-4-digit years Resent-From: Mark H Weaver <mhw@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Sat, 20 Oct 2018 22:42:01 +0000 Resent-Message-ID: <handler.21904.B21904.15400752867288 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 21904 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Zefram <zefram@HIDDEN> Cc: 21904 <at> debbugs.gnu.org Received: via spool by 21904-submit <at> debbugs.gnu.org id=B21904.15400752867288 (code B ref 21904); Sat, 20 Oct 2018 22:42:01 +0000 Received: (at 21904) by debbugs.gnu.org; 20 Oct 2018 22:41:26 +0000 Received: from localhost ([127.0.0.1]:33590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1gDzvx-0001tU-OA for submit <at> debbugs.gnu.org; Sat, 20 Oct 2018 18:41:25 -0400 Received: from world.peace.net ([64.112.178.59]:36162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mhw@HIDDEN>) id 1gDzvv-0001tE-Jh for 21904 <at> debbugs.gnu.org; Sat, 20 Oct 2018 18:41:23 -0400 Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from <mhw@HIDDEN>) id 1gDzvp-0000KR-MP; Sat, 20 Oct 2018 18:41:17 -0400 From: Mark H Weaver <mhw@HIDDEN> References: <20151113142229.GO13455@HIDDEN> Date: Sat, 20 Oct 2018 18:41:05 -0400 In-Reply-To: <20151113142229.GO13455@HIDDEN> (Zefram's message of "Fri, 13 Nov 2015 14:22:29 +0000") Message-ID: <87h8hg2qda.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Zefram <zefram@HIDDEN> writes: > scheme@(guile-user)> (date->string (julian-day->date 1722000 0) "~1") > $4 = "2-07-29" > scheme@(guile-user)> (date->string (julian-day->date 1730000 0) "~1") > $5 = "24-06-23" > scheme@(guile-user)> (date->string (julian-day->date 2000000 0) "~1") > $6 = "763-09-18" This particular subset of bugs, for years 0-9999, was fixed in the upstream SRFI-19 reference implementation, and so I included the same fix in commit 5106377a3460e1e35daf14ea6edbe80426347155. That fix pads the year to have at least 4 characters with the requested padding character (0 by default). However, it does not handle adding the sign where mandated by ISO 8601. As with your related bug <https://bugs.gnu.org/21903>, I think this bug should be reported to upstream SRFI-19, and hopefully they will take it seriously. I'm reluctant to have Guile deviate from most (all?) other SRFI-19 implementations in this respect. There's also the issue that 'string->date' would need to be fixed to successfully parse the years as printed by 'date->string'. Would you like to report these issues to upstream SRFI-19? Regards, Mark
X-Loop: help-debbugs@HIDDEN Subject: bug#21904: date->string duff ISO 8601 format for non-4-digit years Resent-From: Mark H Weaver <mhw@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Sun, 21 Oct 2018 00:35:02 +0000 Resent-Message-ID: <handler.21904.B21904.1540082078680 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 21904 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Zefram <zefram@HIDDEN> Cc: 21904 <at> debbugs.gnu.org Received: via spool by 21904-submit <at> debbugs.gnu.org id=B21904.1540082078680 (code B ref 21904); Sun, 21 Oct 2018 00:35:02 +0000 Received: (at 21904) by debbugs.gnu.org; 21 Oct 2018 00:34:38 +0000 Received: from localhost ([127.0.0.1]:33644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1gE1hV-0000At-QS for submit <at> debbugs.gnu.org; Sat, 20 Oct 2018 20:34:38 -0400 Received: from world.peace.net ([64.112.178.59]:41578) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mhw@HIDDEN>) id 1gE1hU-0000Ag-Tf for 21904 <at> debbugs.gnu.org; Sat, 20 Oct 2018 20:34:37 -0400 Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from <mhw@HIDDEN>) id 1gE1hN-0001hS-TU; Sat, 20 Oct 2018 20:34:30 -0400 From: Mark H Weaver <mhw@HIDDEN> References: <20151113142229.GO13455@HIDDEN> Date: Sat, 20 Oct 2018 20:34:10 -0400 In-Reply-To: <20151113142229.GO13455@HIDDEN> (Zefram's message of "Fri, 13 Nov 2015 14:22:29 +0000") Message-ID: <87woqc16kd.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Zefram <zefram@HIDDEN> writes: > For year numbers 10000 and above, it is necessary to use more than four > digits for the year, and that's permitted, but ISO 8601 requires that > more than four digits are preceded by a sign. For positive year numbers > the sign must be "+". So one should write "+22666" rather than "22666", > for example. I skimmed a draft of ISO 8601 that I was able to find gratis online: https://web.archive.org/web/20171019211402/https://www.loc.gov/standards/= datetime/ISO_DIS%208601-1.pdf https://web.archive.org/web/20171020000043/https://www.loc.gov/standards/= datetime/ISO_DIS%208601-2.pdf and also the ISO 8601 Wikipedia page: https://en.wikipedia.org/wiki/ISO_8601#Years and I'm left with a different interpretation about what the standard permits. As the Wikipedia page says: To represent years before 0000 or after 9999, the standard also permits the expansion of the year representation but only by prior agreement between the sender and the receiver.[19] An expanded year representation [=C2=B1YYYYY] must have an agreed-upon number of extra year digits beyond the four-digit minimum, and it must be prefixed with a + or =E2=88=92 sign[20] [...] Note the words "but only by prior agreement between the sender and the receiver", and "must have an agreed-upon number of extra year digits". You seem to have reached the conclusion that the sender can choose the number of digits dynamically, leaving the receiver to auto-detect the number of digits, but that seems to contradict to requirements given above. My interpretation is that although ISO 8601 permits the use of expanded year formats, it seems to require that in a given format, the year must have a fixed number of digits, and it must _always_ include a sign. In other words, the receiver should know ahead of time, by prior agreement, how many digits to expect, and there should _always_ be a sign, even if the year happens to be in the range 0-9999. In order to support years outside the range 0-9999 and in accordance with ISO 8601, I think that 'date->string' and 'string->date' would need to be extended to allow the caller to specify how many digits to use in the expanded 'year' format, presumably by adding a new format escape. If the specified number of digits is greater than 4, then a sign would *always* be printed. 'string->date' would know how many digits to expect, and whether to expect a sign. Ideally, such an extension of 'date->string' and 'string->date' would be adopted by upstream SRFI-19. However, if that's unsuccessful, I'd be open to unilaterally adding such an extension. There's precedent for this in Guile, e.g. see our (srfi srfi-9 gnu) extensions to SRFI-9. Another question is whether or not we should raise an exception when attempting to print a year that cannot be represented in the requested year format. What do you think? Mark
X-Loop: help-debbugs@HIDDEN Subject: bug#21904: date->string duff ISO 8601 format for non-4-digit years Resent-From: Mark H Weaver <mhw@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Sun, 21 Oct 2018 03:54:02 +0000 Resent-Message-ID: <handler.21904.B21904.154009402818483 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 21904 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: Zefram <zefram@HIDDEN> Cc: 21904 <at> debbugs.gnu.org Received: via spool by 21904-submit <at> debbugs.gnu.org id=B21904.154009402818483 (code B ref 21904); Sun, 21 Oct 2018 03:54:02 +0000 Received: (at 21904) by debbugs.gnu.org; 21 Oct 2018 03:53:48 +0000 Received: from localhost ([127.0.0.1]:33707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1gE4oG-0004o3-2W for submit <at> debbugs.gnu.org; Sat, 20 Oct 2018 23:53:48 -0400 Received: from world.peace.net ([64.112.178.59]:48132) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mhw@HIDDEN>) id 1gE4oE-0004nq-Lv for 21904 <at> debbugs.gnu.org; Sat, 20 Oct 2018 23:53:47 -0400 Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from <mhw@HIDDEN>) id 1gE4o8-0003cz-Pv; Sat, 20 Oct 2018 23:53:40 -0400 From: Mark H Weaver <mhw@HIDDEN> References: <20151113142229.GO13455@HIDDEN> <87woqc16kd.fsf@HIDDEN> Date: Sat, 20 Oct 2018 23:53:24 -0400 In-Reply-To: <87woqc16kd.fsf@HIDDEN> (Mark H. Weaver's message of "Sat, 20 Oct 2018 20:34:10 -0400") Message-ID: <87efck0xcb.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Mark H Weaver <mhw@HIDDEN> writes: > Another question is whether or not we should raise an exception when > attempting to print a year that cannot be represented in the requested > year format. I thought about it some more, and I'm now inclined to think that the approach in your patches is reasonable, or at least it's the least bad thing we can do when asked to print a year that doesn't fit within the standard format, given the existing SRFI-19 API. I also just noticed that the SRFI-19's reference implementation's formatting of negative years is very badly broken (e.g. it prints "00-2" when the year field is -2) and Guile had the same behavior after I applied the fix from upstream to pad the year to 4 digits. So, for now, I went ahead and implemented the behavior that you recommended, with one difference: where you hardcode the padding character to #\0 when formatting years, I use the padding character specified by the user, following the SRFI-19 reference implementation. What do you think? Mark
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.