Properly handle %W in strptime
authorAndreas Schwab <schwab@suse.de>
Tue, 5 Feb 2013 13:40:39 +0000 (14:40 +0100)
committerAndreas Schwab <schwab@suse.de>
Wed, 5 Jun 2013 08:33:02 +0000 (10:33 +0200)
ChangeLog
NEWS
time/strptime_l.c
time/tst-strptime.c

index 69f3b9f..9a2a0c5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-06-05  Andreas Schwab  <schwab@suse.de>
+
+       [BZ #15100]
+       * time/strptime_l.c (__strptime_internal): Count Sunday in a %W
+       week as 6 instead of -1.
+       * time/tst-strptime.c (day_tests): Add test case.
+
 2013-06-05  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
        * sysdeps/generic/math_private.h
diff --git a/NEWS b/NEWS
index 9452cc1..3068b78 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,12 +14,12 @@ Version 2.18
   14293, 14317, 14327, 14478, 14496, 14582, 14686, 14812, 14888, 14894,
   14908, 14920, 14952, 14964, 14981, 14982, 14985, 14994, 14996, 15000,
   15003, 15006, 15007, 15014, 15020, 15023, 15036, 15054, 15055, 15062,
-  15078, 15084, 15085, 15086, 15160, 15214, 15221, 15232, 15234, 15283,
-  15285, 15287, 15304, 15305, 15307, 15309, 15327, 15330, 15335, 15336,
-  15337, 15339, 15342, 15346, 15359, 15361, 15366, 15380, 15381, 15394,
-  15395, 15405, 15406, 15409, 15416, 15418, 15419, 15423, 15424, 15426,
-  15429, 15441, 15442, 15448, 15465, 15480, 15485, 15488, 15490, 15493,
-  15497, 15506, 15529, 15536, 15553.
+  15078, 15084, 15085, 15086, 15100, 15160, 15214, 15221, 15232, 15234,
+  15283, 15285, 15287, 15304, 15305, 15307, 15309, 15327, 15330, 15335,
+  15336, 15337, 15339, 15342, 15346, 15359, 15361, 15366, 15380, 15381,
+  15394, 15395, 15405, 15406, 15409, 15416, 15418, 15419, 15423, 15424,
+  15426, 15429, 15441, 15442, 15448, 15465, 15480, 15485, 15488, 15490,
+  15493, 15497, 15506, 15529, 15536, 15553.
 
 * CVE-2013-0242 Buffer overrun in regexp matcher has been fixed (Bugzilla
   #15078).
index 1f2e8b6..00fc1ef 100644 (file)
@@ -1180,8 +1180,8 @@ __strptime_internal (rp, fmt, tmp, statep LOCALE_PARAM)
 
       if (!s.have_yday)
        tm->tm_yday = ((7 - (tm->tm_wday - w_offset)) % 7
-                      + (s.week_no - 1) *7
-                      + save_wday - w_offset);
+                      + (s.week_no - 1) * 7
+                      + (save_wday - w_offset + 7) % 7);
 
       if (!s.have_mday || !s.have_mon)
        {
index 12b084d..21fbb63 100644 (file)
@@ -41,6 +41,7 @@ static const struct
   { "C", "19990502123412", "%Y%m%d%H%M%S", 0, 121, 4, 2 },
   { "C", "2001 20 Mon", "%Y %U %a", 1, 140, 4, 21 },
   { "C", "2001 21 Mon", "%Y %W %a", 1, 140, 4, 21 },
+  { "C", "2012 00 Sun", "%Y %W %a", 0, 0, 0, 1 },
   { "ja_JP.EUC-JP", "2000-01-01 08:12:21 AM", "%Y-%m-%d %I:%M:%S %p",
     6, 0, 0, 1 },
   { "en_US.ISO-8859-1", "2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p",