1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-25 04:40:19 +02:00

Fixed bug: ~N mishandles small nanoseconds value

Fixes <http://bugs.gnu.org/26261>.
Reported by Zefram <zefram@fysh.org>.

* module/srfi/srfi-19.scm ("define directives"): N padding increased from 7 to 9

* test-suite/tests/srfi-19.test ("date->string"): New test.
This commit is contained in:
Andrew Moss 2017-03-27 11:58:29 -04:00 committed by Andy Wingo
parent b11e2922c3
commit 1978085b22
2 changed files with 6 additions and 1 deletions

View file

@ -1063,7 +1063,7 @@
(newline port))) (newline port)))
(cons #\N (lambda (date pad-with port) (cons #\N (lambda (date pad-with port)
(display (padding (date-nanosecond date) (display (padding (date-nanosecond date)
pad-with 7) pad-with 9)
port))) port)))
(cons #\p (lambda (date pad-with port) (cons #\p (lambda (date pad-with port)
(display (locale-am-string/pm (date-hour date)) port))) (display (locale-am-string/pm (date-hour date)) port)))

View file

@ -175,6 +175,11 @@ incomplete numerical tower implementation.)"
(equal? "Sun Jun 05 18:33:00+0200 2005" (equal? "Sun Jun 05 18:33:00+0200 2005"
(date->string date)))) (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 ;; check time comparison procedures
(let* ((time1 (make-time time-monotonic 0 0)) (let* ((time1 (make-time time-monotonic 0 0))
(time2 (make-time time-monotonic 0 0)) (time2 (make-time time-monotonic 0 0))