unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Zefram <zefram@fysh.org>
To: 21903@debbugs.gnu.org
Subject: bug#21903: date->string duff ISO 8601 negative years
Date: Thu, 20 Apr 2017 01:09:11 +0100	[thread overview]
Message-ID: <20170420000911.GE912@fysh.org> (raw)
In-Reply-To: <20151113140157.GN13455@fysh.org>

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

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

[-- Attachment #2: 0002-fix-SRFI-19-s-ISO-8601-year-numbering.patch --]
[-- Type: text/x-diff, Size: 1317 bytes --]

From 3d39f1dfa0e210282db48a9af828646d7e9acef3 Mon Sep 17 00:00:00 2001
From: Zefram <zefram@fysh.org>
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


  reply	other threads:[~2017-04-20  0:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-13 14:01 bug#21903: date->string duff ISO 8601 negative years Zefram
2017-04-20  0:09 ` Zefram [this message]
2018-10-20 22:33 ` Mark H Weaver
2018-10-21  0:40   ` Mark H Weaver
2018-10-21  4:01     ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170420000911.GE912@fysh.org \
    --to=zefram@fysh.org \
    --cc=21903@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).