From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Zefram Newsgroups: gmane.lisp.guile.bugs Subject: bug#21904: date->string duff ISO 8601 format for non-4-digit years Date: Fri, 13 Nov 2015 14:22:29 +0000 Message-ID: <20151113142229.GO13455@fysh.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1447424607 4037 80.91.229.3 (13 Nov 2015 14:23:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Nov 2015 14:23:27 +0000 (UTC) To: 21904@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Fri Nov 13 15:23:14 2015 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZxFFs-0005co-RX for guile-bugs@m.gmane.org; Fri, 13 Nov 2015 15:23:09 +0100 Original-Received: from localhost ([::1]:53306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxFFs-0002jx-B6 for guile-bugs@m.gmane.org; Fri, 13 Nov 2015 09:23:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxFFn-0002jo-8k for bug-guile@gnu.org; Fri, 13 Nov 2015 09:23:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxFFm-0003Vm-7I for bug-guile@gnu.org; Fri, 13 Nov 2015 09:23:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxFFm-0003Vi-3F for bug-guile@gnu.org; Fri, 13 Nov 2015 09:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZxFFl-0002R1-NU for bug-guile@gnu.org; Fri, 13 Nov 2015 09:23:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Zefram Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 13 Nov 2015 14:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21904 X-GNU-PR-Package: guile X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14474245629328 (code B ref -1); Fri, 13 Nov 2015 14:23:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Nov 2015 14:22:42 +0000 Original-Received: from localhost ([127.0.0.1]:36826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZxFFR-0002QM-QG for submit@debbugs.gnu.org; Fri, 13 Nov 2015 09:22:42 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48575) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZxFFP-0002QE-BG for submit@debbugs.gnu.org; Fri, 13 Nov 2015 09:22:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxFFO-0003QE-HR for submit@debbugs.gnu.org; Fri, 13 Nov 2015 09:22:39 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:35567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxFFO-0003QA-EK for submit@debbugs.gnu.org; Fri, 13 Nov 2015 09:22:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxFFK-0002dm-3j for bug-guile@gnu.org; Fri, 13 Nov 2015 09:22:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxFFJ-0003OY-5b for bug-guile@gnu.org; Fri, 13 Nov 2015 09:22:34 -0500 Original-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 ) id 1ZxFFI-0003ON-Vk for bug-guile@gnu.org; Fri, 13 Nov 2015 09:22:33 -0500 Original-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 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7899 Archived-At: 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