srfi-19: Fix `string->date' weekday lookup.
authorLudovic Courtès <ludo@gnu.org>
Thu, 18 Dec 2008 21:34:23 +0000 (22:34 +0100)
committerLudovic Courtès <ludo@gnu.org>
Thu, 18 Dec 2008 21:49:13 +0000 (22:49 +0100)
* srfi/srfi-19.scm (priv:locale-abbr-weekday->index): Use
  `locale-day-short' since it expects integers in the range 1-7, unlike
  `priv:locale-abbr-weekday'.
  (priv:locale-long-weekday->index): Likewise.

* test-suite/tests/srfi-19.test ("SRFI date/time
  library")["string->date works on Sunday"]: New test.

srfi/srfi-19.scm
test-suite/tests/srfi-19.test

index 96ef344..1863fd3 100644 (file)
           (else (loop (+ index 1))))))
 
 (define (priv:locale-abbr-weekday->index string)
-  (priv:date-reverse-lookup string priv:locale-abbr-weekday 7 string=?))
+  (priv:date-reverse-lookup string locale-day-short 7 string=?))
 
 (define (priv:locale-long-weekday->index string)
-  (priv:date-reverse-lookup string priv:locale-long-weekday 7 string=?))
+  (priv:date-reverse-lookup string locale-day 7 string=?))
 
 (define (priv:locale-abbr-month->index string)
   (priv:date-reverse-lookup string priv:locale-abbr-month  12 string=?))
index a553ce4..259a88a 100644 (file)
@@ -1,7 +1,7 @@
 ;;;; srfi-19.test --- test suite for SRFI-19 -*- scheme -*-
 ;;;; Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> --- June 2001
 ;;;;
-;;;;   Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;;;   Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 ;;;;
 ;;;; This program is free software; you can redistribute it and/or modify
 ;;;; it under the terms of the GNU General Public License as published by
@@ -166,6 +166,14 @@ incomplete numerical tower implementation.)"
                                                 0)))
                    (date->time-utc
                     (make-date 0 0 0 0 9 12 2006 0))))
+
+  (pass-if "string->date works on Sunday"
+    ;; `string->date' never rests!
+    (let* ((str  "Sun, 05 Jun 2005 18:33:00 +0200")
+           (date (string->date str "~a, ~d ~b ~Y ~H:~M:~S ~z")))
+      (equal? "Sun Jun 05 18:33:00+0200 2005"
+              (date->string date))))
+
   ;; check time comparison procedures
   (let* ((time1 (make-time time-monotonic 0 0))
          (time2 (make-time time-monotonic 0 0))