From e975f8ae8d494985a51faed5b15c5664a557e0e2 Mon Sep 17 00:00:00 2001
From: Andrew Moss
Date: Mon, 27 Mar 2017 11:58:29 -0400
Subject: [PATCH] Fixed bug: ~N mishandles small nanoseconds value
Fixes .
Reported by Zefram .
* module/srfi/srfi-19.scm ("define directives"): N padding increased from 7 to 9
* test-suite/tests/srfi-19.test ("date->string"): New test.
---
module/srfi/srfi-19.scm | 2 +-
test-suite/tests/srfi-19.test | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/module/srfi/srfi-19.scm b/module/srfi/srfi-19.scm
index 658ccd9..4823f2f 100644
--- a/module/srfi/srfi-19.scm
+++ b/module/srfi/srfi-19.scm
@@ -1060,7 +1060,7 @@
(newline port)))
(cons #\N (lambda (date pad-with port)
(display (padding (date-nanosecond date)
- pad-with 7)
+ pad-with 9)
port)))
(cons #\p (lambda (date pad-with port)
(display (locale-am-string/pm (date-hour date)) port)))
diff --git a/test-suite/tests/srfi-19.test b/test-suite/tests/srfi-19.test
index d63e622..534cd7c 100644
--- a/test-suite/tests/srfi-19.test
+++ b/test-suite/tests/srfi-19.test
@@ -175,6 +175,11 @@ incomplete numerical tower implementation.)"
(equal? "Sun Jun 05 18:33:00+0200 2005"
(date->string date))))
+ (pass-if "date->string pads small nanoseconds values correctly"
+ (let* ((date (make-date 99999999 5 34 12 26 3 2017 0)))
+ (equal? "099999999"
+ (date->string date "~N"))))
+
;; check time comparison procedures
(let* ((time1 (make-time time-monotonic 0 0))
(time2 (make-time time-monotonic 0 0))
--
2.7.4