unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* srfi-19 date-week-number gremlin
@ 2003-08-13  0:08 Kevin Ryde
  2003-10-05 15:24 ` Marius Vollmer
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ryde @ 2003-08-13  0:08 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: srfi-19 date-week-number gremlin
  2003-08-13  0:08 srfi-19 date-week-number gremlin Kevin Ryde
@ 2003-10-05 15:24 ` Marius Vollmer
  2003-10-06 23:23   ` Kevin Ryde
  0 siblings, 1 reply; 3+ messages in thread
From: Marius Vollmer @ 2003-10-05 15:24 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> 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.

Yes, please.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: srfi-19 date-week-number gremlin
  2003-10-05 15:24 ` Marius Vollmer
@ 2003-10-06 23:23   ` Kevin Ryde
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Ryde @ 2003-10-06 23:23 UTC (permalink / raw)
  Cc: guile-devel

Marius Vollmer <mvo@zagadka.de> writes:
>
> Yes, please.

Beaut, already done.


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-10-06 23:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-13  0:08 srfi-19 date-week-number gremlin Kevin Ryde
2003-10-05 15:24 ` Marius Vollmer
2003-10-06 23:23   ` Kevin Ryde

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).