unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Subject: srfi-19 date-week-number gremlin
Date: Wed, 13 Aug 2003 10:08:32 +1000	[thread overview]
Message-ID: <87ekzq1ksf.fsf@zip.com.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 635 bytes --]

I noticed srfi-19 date-week-number seems to be off by 1 in its week
start calculation.  For instance looking at Jan 1984, Sat 7th should
be in the first week and Sun 8th begin the next, but alas,

	(date-week-number (make-date 0 0 0 0 7 1 1984 0) 0)
	(date-week-number (make-date 0 0 0 0 8 1 1984 0) 0)

both give 1.

The code looks about right, just doesn't take into account
date-year-day starting from 1 rather than 0.

        * srfi-19.scm (date-week-number): Correction, day of week starting
        week was off by one.

        * tests/srfi-19.test (date-week-number): Add tests.

I think this could go in the 1.6 branch too.


[-- Attachment #2: srfi-19.scm.dwn.diff --]
[-- Type: text/plain, Size: 339 bytes --]

--- srfi-19.scm.~1.18.~	2003-04-07 08:05:30.000000000 +1000
+++ srfi-19.scm	2003-07-23 09:08:22.000000000 +1000
@@ -823,6 +823,7 @@
 
 (define (date-week-number date day-of-week-starting-week)
   (quotient (- (date-year-day date)
+	       1
                (priv:days-before-first-week  date day-of-week-starting-week))
             7))
 

[-- Attachment #3: srfi-19.test.dwn.diff --]
[-- Type: text/plain, Size: 770 bytes --]

--- srfi-19.test.~1.2.~	2002-08-07 10:52:21.000000000 +1000
+++ srfi-19.test	2003-08-13 10:03:17.000000000 +1000
@@ -150,7 +150,13 @@
          (time2 (make-time time-monotonic 385907 998360432))
          (diff (time-difference time2 time1)))
     (test-time-arithmetic add-duration time1 diff time2)
-    (test-time-arithmetic subtract-duration time2 diff time1)))
+    (test-time-arithmetic subtract-duration time2 diff time1))
+
+  (with-test-prefix "date-week-number"
+    (pass-if (= 0 (date-week-number (make-date 0 0 0 0 1 1 1984 0) 0)))
+    (pass-if (= 0 (date-week-number (make-date 0 0 0 0 7 1 1984 0) 0)))
+    (pass-if (= 1 (date-week-number (make-date 0 0 0 0 8 1 1984 0) 0)))))
+
 
 ;; Local Variables:
 ;; eval: (put 'with-tz 'scheme-indent-function 1)

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

             reply	other threads:[~2003-08-13  0:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-13  0:08 Kevin Ryde [this message]
2003-10-05 15:24 ` srfi-19 date-week-number gremlin Marius Vollmer
2003-10-06 23:23   ` Kevin Ryde

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=87ekzq1ksf.fsf@zip.com.au \
    --to=user42@zip.com.au \
    /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).