unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Zefram <zefram@fysh.org>
To: 26165@debbugs.gnu.org
Subject: bug#26165: date-week-day screws up prior to AD 1
Date: Sat, 18 Mar 2017 23:45:28 +0000	[thread overview]
Message-ID: <20170318234528.GL6518@fysh.org> (raw)

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





             reply	other threads:[~2017-03-18 23:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-18 23:45 Zefram [this message]
2017-03-19  1:01 ` bug#26165: date-week-day screws up prior to AD 1 Zefram
2018-10-21 20:41 ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170318234528.GL6518@fysh.org \
    --to=zefram@fysh.org \
    --cc=26165@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).