From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: srfi-19 date-week-number gremlin Date: Wed, 13 Aug 2003 10:08:32 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87ekzq1ksf.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1060733559 30840 80.91.224.253 (13 Aug 2003 00:12:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Aug 2003 00:12:39 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Aug 13 02:12:38 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19mjFl-0001Kt-01 for ; Wed, 13 Aug 2003 02:12:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mjCk-0007uH-2Z for guile-devel@m.gmane.org; Tue, 12 Aug 2003 20:09:30 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19mjCc-0007pe-TS for guile-devel@gnu.org; Tue, 12 Aug 2003 20:09:22 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19mjC6-0007Ap-Kr for guile-devel@gnu.org; Tue, 12 Aug 2003 20:09:21 -0400 Original-Received: from [61.8.0.36] (helo=snoopy.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mjC5-0007A4-Ty for guile-devel@gnu.org; Tue, 12 Aug 2003 20:08:50 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.4) with ESMTP id h7D08m0J003081 for ; Wed, 13 Aug 2003 10:08:48 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h7D08lkv019864 for ; Wed, 13 Aug 2003 10:08:47 +1000 (EST) Original-Received: from localhost (ppp123.dyn228.pacific.net.au [203.143.228.123]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h7D08ios008877 for ; Wed, 13 Aug 2003 10:08:46 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19mjBq-0006dT-00; Wed, 13 Aug 2003 10:08:34 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2692 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2692 --=-=-= 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. --=-=-= Content-Disposition: attachment; filename=srfi-19.scm.dwn.diff --- 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)) --=-=-= Content-Disposition: attachment; filename=srfi-19.test.dwn.diff --- 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) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--