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"
>From befdf71b04a0d1c02947457baa3c7e5f152b7e8e Mon Sep 17 00:00:00 2001
From: Ian Price <[email protected]>
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