unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#12246: [patch] iso 8601 specifies zero padding, not space padding
@ 2012-08-21 11:21 Ian Price
  2012-08-26 22:21 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Price @ 2012-08-21 11:21 UTC (permalink / raw
  To: 12246

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


In srfi 19, there is convenience format directives for various ISO 8601
date/time formats. i.e.

     ~2     ISO-8601 time+zone, `~k:~M:~S~z'
     ~3     ISO-8601 time, `~k:~M:~S'
     ~4     ISO-8601 date/time+zone, `~Y-~m-~dT~k:~M:~S~z'
     ~5     ISO-8601 date/time, `~Y-~m-~dT~k:~M:~S'

However, ~k is incorrect here, as iso 8601 specifies that hours have two
digits (i.e. 9am is "09") which means the ~H directive.

Funnily enough, if you look in srfi-19.scm itself you even see

(define iso-8601-date-time-format "~Y-~m-~dT~H:~M:~S~z")

note, the ~H.

I've attached a patch to fix these.
     
-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: srfi-19 patch --]
[-- Type: text/x-patch, Size: 2561 bytes --]

From befdf71b04a0d1c02947457baa3c7e5f152b7e8e Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Tue, 21 Aug 2012 12:13:25 +0100
Subject: [PATCH] ISO 8601 time format specifies zero padding for hours, not
 blank padding.

* doc/ref/srfi-modules.texi ("SRFI-19 Date to string"): Fix iso 8601 format strings.
* module/srfi/srfi-19.scm (directives): Fix iso 8601 format strings.
---
 doc/ref/srfi-modules.texi |    8 ++++----
 module/srfi/srfi-19.scm   |    8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index fdc316f..4fbe250 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -2997,10 +2997,10 @@ with locale decimal point, eg.@: @samp{5.2}
 @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}
-@item @nicode{~2} @tab ISO-8601 time+zone, @samp{~k:~M:~S~z}
-@item @nicode{~3} @tab ISO-8601 time, @samp{~k:~M:~S}
-@item @nicode{~4} @tab ISO-8601 date/time+zone, @samp{~Y-~m-~dT~k:~M:~S~z}
-@item @nicode{~5} @tab ISO-8601 date/time, @samp{~Y-~m-~dT~k:~M:~S}
+@item @nicode{~2} @tab ISO-8601 time+zone, @samp{~H:~M:~S~z}
+@item @nicode{~3} @tab ISO-8601 time, @samp{~H:~M:~S}
+@item @nicode{~4} @tab ISO-8601 date/time+zone, @samp{~Y-~m-~dT~H:~M:~S~z}
+@item @nicode{~5} @tab ISO-8601 date/time, @samp{~Y-~m-~dT~H:~M:~S}
 @end multitable
 @end defun
 
diff --git a/module/srfi/srfi-19.scm b/module/srfi/srfi-19.scm
index d8f7643..c0a27b1 100644
--- a/module/srfi/srfi-19.scm
+++ b/module/srfi/srfi-19.scm
@@ -1113,13 +1113,13 @@
    (cons #\1 (lambda (date pad-with port)
                (display (date->string date "~Y-~m-~d") port)))
    (cons #\2 (lambda (date pad-with port)
-               (display (date->string date "~k:~M:~S~z") port)))
+               (display (date->string date "~H:~M:~S~z") port)))
    (cons #\3 (lambda (date pad-with port)
-               (display (date->string date "~k:~M:~S") port)))
+               (display (date->string date "~H:~M:~S") port)))
    (cons #\4 (lambda (date pad-with port)
-               (display (date->string date "~Y-~m-~dT~k:~M:~S~z") port)))
+               (display (date->string date "~Y-~m-~dT~H:~M:~S~z") port)))
    (cons #\5 (lambda (date pad-with port)
-               (display (date->string date "~Y-~m-~dT~k:~M:~S") port)))))
+               (display (date->string date "~Y-~m-~dT~H:~M:~S") port)))))
 
 
 (define (get-formatter char)
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#12246: [patch] iso 8601 specifies zero padding, not space padding
  2012-08-21 11:21 bug#12246: [patch] iso 8601 specifies zero padding, not space padding Ian Price
@ 2012-08-26 22:21 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2012-08-26 22:21 UTC (permalink / raw
  To: Ian Price; +Cc: 12246-done

Applied, thanks!

Ludo'.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-26 22:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-21 11:21 bug#12246: [patch] iso 8601 specifies zero padding, not space padding Ian Price
2012-08-26 22:21 ` Ludovic Courtès

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).