unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#26261: ~N mishandles small nanoseconds value
@ 2017-03-26  2:19 Zefram
  2017-03-27 16:06 ` Andrew Moss
  0 siblings, 1 reply; 3+ messages in thread
From: Zefram @ 2017-03-26  2:19 UTC (permalink / raw)
  To: 26261

The ~N format specifier in SRFI-19's date->string is documented to show
the nanoseconds value, with zero padding.  The documentation explicates
further by showing as an example a string of nine zeroes.  In fact the
implementation only pads to seven digits, and so produces incorrect
output for and nanoseconds value in the range [0, 100000000):

scheme@(guile-user)> (use-modules (srfi srfi-19))
scheme@(guile-user)> (date->string (make-date 0 5 34 12 26 3 2017 0) "~N")
$1 = "0000000"
scheme@(guile-user)> (date->string (make-date 2 5 34 12 26 3 2017 0) "~N")
$2 = "0000002"
scheme@(guile-user)> (date->string (make-date 200 5 34 12 26 3 2017 0) "~N")
$3 = "0000200"
scheme@(guile-user)> (date->string (make-date 200000 5 34 12 26 3 2017 0) "~N")
$4 = "0200000"
scheme@(guile-user)> (date->string (make-date 99999999 5 34 12 26 3 2017 0) "~N")
$5 = "99999999"
scheme@(guile-user)> (date->string (make-date 200000000 5 34 12 26 3 2017 0) "~N")
$6 = "200000000"

The padding clearly has to be to the full nine digits.

-zefram





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

end of thread, other threads:[~2017-04-19 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-26  2:19 bug#26261: ~N mishandles small nanoseconds value Zefram
2017-03-27 16:06 ` Andrew Moss
2017-04-19 13:14   ` Andy Wingo

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