From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Zefram Newsgroups: gmane.lisp.guile.bugs Subject: bug#21903: date->string duff ISO 8601 negative years Date: Thu, 20 Apr 2017 01:09:11 +0100 Message-ID: <20170420000911.GE912@fysh.org> References: <20151113140157.GN13455@fysh.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Q0rSlbzrZN6k9QnT" X-Trace: blaine.gmane.org 1492647010 31341 195.159.176.226 (20 Apr 2017 00:10:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2017 00:10:10 +0000 (UTC) To: 21903@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Apr 20 02:10:06 2017 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 1d0zfh-000813-Bz for guile-bugs@m.gmane.org; Thu, 20 Apr 2017 02:10:05 +0200 Original-Received: from localhost ([::1]:51022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0zfn-0005zJ-AT for guile-bugs@m.gmane.org; Wed, 19 Apr 2017 20:10:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0zfi-0005z5-1q for bug-guile@gnu.org; Wed, 19 Apr 2017 20:10:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0zfe-0006NA-TB for bug-guile@gnu.org; Wed, 19 Apr 2017 20:10:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d0zfe-0006N1-PM for bug-guile@gnu.org; Wed, 19 Apr 2017 20:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d0zfe-0002lL-Eu for bug-guile@gnu.org; Wed, 19 Apr 2017 20:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Zefram Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 20 Apr 2017 00:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21903 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 21903-submit@debbugs.gnu.org id=B21903.149264695410555 (code B ref 21903); Thu, 20 Apr 2017 00:10:02 +0000 Original-Received: (at 21903) by debbugs.gnu.org; 20 Apr 2017 00:09:14 +0000 Original-Received: from localhost ([127.0.0.1]:57651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0zes-0002kB-7M for submit@debbugs.gnu.org; Wed, 19 Apr 2017 20:09:14 -0400 Original-Received: from river.fysh.org ([87.98.248.19]:33009 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0zer-0002k3-71 for 21903@debbugs.gnu.org; Wed, 19 Apr 2017 20:09:13 -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=bRLD9oOGZ2gTymXFEBO6pYzEn31N3/r26S20Kr9xgNo=; b=qPBEyT1II5WCfBEVItDtDLfRKdfGaZXONlJgB20nd7aEH39QVqYw8m6cFP6V3Bc0iWNd77LxbqsxF2BoL7MuvsG10kbMPha7XaAofKqRp2/EHyNjv1dErB1HwsKZhPxsepMmShGINrL4j5UFkOz+AzSO9Ulg6udhpCtuCr9ptcQ=; Original-Received: from zefram by river.fysh.org with local (Exim 4.84_2 #1 (Debian)) id 1d0zep-0005wD-2O; Thu, 20 Apr 2017 01:09:11 +0100 Content-Disposition: inline In-Reply-To: <20151113140157.GN13455@fysh.org> 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:8770 Archived-At: --Q0rSlbzrZN6k9QnT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline A patch to fix this is attached. It applies on top of my patch for bug#21904. The choice that I described for that bug about whether to change ~Y or to have a separate ISO 8601 year formatter actually applies to both bugs, and the comment that I made there about exposing the non-linear year numbering is really only about this bug. -zefram --Q0rSlbzrZN6k9QnT Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0002-fix-SRFI-19-s-ISO-8601-year-numbering.patch" >From 3d39f1dfa0e210282db48a9af828646d7e9acef3 Mon Sep 17 00:00:00 2001 From: Zefram Date: Thu, 20 Apr 2017 00:53:40 +0100 Subject: [PATCH 2/2] fix SRFI-19's ISO 8601 year numbering The ISO 8601 date formats offered by SRFI-19's date->string function were emitting incorrect year numbers for years preceding AD 1. It was following the non-linear numbering that the library uses in the date structure, rather than the standard astronomical year numbering required by ISO 8601. This is now fixed. As with the preceding fix for the syntax of year numbers, the fix is actually applied to the ~Y format, which SRFI-19 doesn't require to follow ISO 8601. --- module/srfi/srfi-19.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/srfi/srfi-19.scm b/module/srfi/srfi-19.scm index d4308bb..0e56c31 100644 --- a/module/srfi/srfi-19.scm +++ b/module/srfi/srfi-19.scm @@ -1128,7 +1128,8 @@ 2) port))) (cons #\Y (lambda (date pad-with port) - (let ((y (date-year date))) + (let* ((yy (date-year date)) + (y (if (negative? yy) (+ yy 1) yy))) (cond ((negative? y) (display #\- port)) ((>= y 10000) (display #\+ port))) (display (padding (abs y) #\0 4) port)))) -- 2.1.4 --Q0rSlbzrZN6k9QnT--