Subject: bug#26261: closed (Re: bug#26261: ~N mishandles small nanoseconds value)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 19 Apr 2017 13:15:02 +0000

Your bug report

#26261: ~N mishandles small nanoseconds value

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
26261: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26261
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#26261: ~N mishandles small nanoseconds value
From: Andy Wingo <[email-masked]>
To: Andrew Moss <[email-masked]>
Cc: [email-masked]
Date: Wed, 19 Apr 2017 15:14:01 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On Mon 27 Mar 2017 18:06, Andrew Moss <[email-masked]> writes:

> I believe I have fixed this bug, but I'm not sure if I put the test
> case in the right place within the file. Please see the attached
> patch.
>
> From e975f8ae8d494985a51faed5b15c5664a557e0e2 Mon Sep 17 00:00:00 2001
> From: Andrew Moss <[email-masked]>
> Date: Mon, 27 Mar 2017 11:58:29 -0400
> Subject: [PATCH] Fixed bug: ~N mishandles small nanoseconds value
>
> Fixes <http://bugs.gnu.org/26261>.
> Reported by Zefram <[email-masked]>.
>
> * module/srfi/srfi-19.scm ("define directives"): N padding increased from 7 to 9
>
> * test-suite/tests/srfi-19.test ("date->string"): New test.

Applied.  Thank you very very much for the fix!

Andy

Subject: ~N mishandles small nanoseconds value
From: Zefram <[email-masked]>
To: [email-masked]
Date: Sun, 26 Mar 2017 03:19:24 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

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