GNU bug report logs - #26165
date-week-day screws up prior to AD 1

Previous Next

Package: guile;

Reported by: Zefram <zefram <at> fysh.org>

Date: Sat, 18 Mar 2017 23:46:02 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 26165 in the body.
You can then email your comments to 26165 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#26165; Package guile. (Sat, 18 Mar 2017 23:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Zefram <zefram <at> fysh.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 18 Mar 2017 23:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Zefram <zefram <at> fysh.org>
To: bug-guile <at> gnu.org
Subject: date-week-day screws up prior to AD 1
Date: Sat, 18 Mar 2017 23:45:28 +0000
Looking at day of the week, via SRFI-19's date-week-day:

scheme@(guile-user)> (use-modules (srfi srfi-19))
scheme@(guile-user)> (julian-day->date 1721426 0) 
$1 = #<date nanosecond: 0 second: 0 minute: 0 hour: 12 day: 1 month: 1 year: 1 zone-offset: 0>
scheme@(guile-user)> (date-week-day (julian-day->date 1721426 0))
$2 = 1
scheme@(guile-user)> (date-week-day (julian-day->date 1721425 0))
$3 = 6

The output for 0001-01-01, Monday, is correct.  The preceding day is
actually a Sunday, but Saturday was shown.  Looking at the code, this
bug arises for the same reason as the problem with date-year-day raised
in bug#26151.  The date-year value, of the weird zero-skipping year
numbering, is passed to an algorithm that obviously expects astronomical
year numbering.

Looking at the code also reveals a second problem: the algorithm is
written to perform divisions with quotient where it obviously needs
modulo.  This will manifest in erroneous computations for some earlier
years once the above is fixed.

-zefram




Information forwarded to bug-guile <at> gnu.org:
bug#26165; Package guile. (Sun, 19 Mar 2017 01:02:01 GMT) Full text and rfc822 format available.

Message #8 received at 26165 <at> debbugs.gnu.org (full text, mbox):

From: Zefram <zefram <at> fysh.org>
To: 26165 <at> debbugs.gnu.org
Subject: Re: bug#26165: date-week-day screws up prior to AD 1
Date: Sun, 19 Mar 2017 01:01:40 +0000
I wrote:
>written to perform divisions with quotient where it obviously needs
>modulo.

Oops, thinko there.  It needs floor-quotient, the quotient-like function
that uses floor rounding.  modulo is the *remainder*-like function that
uses floor rounding.

-zefram




Reply sent to Mark H Weaver <mhw <at> netris.org>:
You have taken responsibility. (Sun, 21 Oct 2018 20:42:02 GMT) Full text and rfc822 format available.

Notification sent to Zefram <zefram <at> fysh.org>:
bug acknowledged by developer. (Sun, 21 Oct 2018 20:42:02 GMT) Full text and rfc822 format available.

Message #13 received at 26165-done <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Zefram <zefram <at> fysh.org>
Cc: 26165-done <at> debbugs.gnu.org
Subject: Re: bug#26165: date-week-day screws up prior to AD 1
Date: Sun, 21 Oct 2018 16:41:06 -0400
Zefram <zefram <at> fysh.org> writes:

> Looking at day of the week, via SRFI-19's date-week-day:
>
> scheme@(guile-user)> (use-modules (srfi srfi-19))
> scheme@(guile-user)> (julian-day->date 1721426 0) 
> $1 = #<date nanosecond: 0 second: 0 minute: 0 hour: 12 day: 1 month: 1 year: 1 zone-offset: 0>
> scheme@(guile-user)> (date-week-day (julian-day->date 1721426 0))
> $2 = 1
> scheme@(guile-user)> (date-week-day (julian-day->date 1721425 0))
> $3 = 6
>
> The output for 0001-01-01, Monday, is correct.  The preceding day is
> actually a Sunday, but Saturday was shown.  Looking at the code, this
> bug arises for the same reason as the problem with date-year-day raised
> in bug#26151.

This is fixed by commit a58c7abd72648f77e4ede5f62a2c4e7969bb7f95 on the
stable-2.2 branch.  I'm closing this bug now, but please reopen if
appropriate.

     Thanks!
       Mark




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 19 Nov 2018 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 158 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.