* bug#26165: date-week-day screws up prior to AD 1
@ 2017-03-18 23:45 Zefram
2017-03-19 1:01 ` Zefram
2018-10-21 20:41 ` Mark H Weaver
0 siblings, 2 replies; 3+ messages in thread
From: Zefram @ 2017-03-18 23:45 UTC (permalink / raw)
To: 26165
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#26165: date-week-day screws up prior to AD 1
2017-03-18 23:45 bug#26165: date-week-day screws up prior to AD 1 Zefram
@ 2017-03-19 1:01 ` Zefram
2018-10-21 20:41 ` Mark H Weaver
1 sibling, 0 replies; 3+ messages in thread
From: Zefram @ 2017-03-19 1:01 UTC (permalink / raw)
To: 26165
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#26165: date-week-day screws up prior to AD 1
2017-03-18 23:45 bug#26165: date-week-day screws up prior to AD 1 Zefram
2017-03-19 1:01 ` Zefram
@ 2018-10-21 20:41 ` Mark H Weaver
1 sibling, 0 replies; 3+ messages in thread
From: Mark H Weaver @ 2018-10-21 20:41 UTC (permalink / raw)
To: Zefram; +Cc: 26165-done
Zefram <zefram@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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-21 20:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-18 23:45 bug#26165: date-week-day screws up prior to AD 1 Zefram
2017-03-19 1:01 ` Zefram
2018-10-21 20:41 ` Mark H Weaver
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).