diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-19 17:13:25 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-19 17:13:25 (GMT) |
commit | d54c2e3f133a772dc71cc776a476face4c90389a (patch) | |
tree | 5801b0f9f764c13b1132cf280a3049c6b5b83602 /Lib/test/test_strptime.py | |
parent | 6a74a51b28979e71e8ae7d79e7cb06d49e67ac07 (diff) | |
download | cpython-d54c2e3f133a772dc71cc776a476face4c90389a.zip cpython-d54c2e3f133a772dc71cc776a476face4c90389a.tar.gz cpython-d54c2e3f133a772dc71cc776a476face4c90389a.tar.bz2 |
Issue #23136: _strptime now uniformly handles all days in week 0, including
Jan 30 of previous year. Based on patch by Jim Carroll.
Diffstat (limited to 'Lib/test/test_strptime.py')
-rw-r--r-- | Lib/test/test_strptime.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py index 66b9ab3..7a47f9e 100644 --- a/Lib/test/test_strptime.py +++ b/Lib/test/test_strptime.py @@ -484,6 +484,24 @@ class CalculationTests(unittest.TestCase): test_helper((2006, 12, 31), "Last Sunday of 2006") test_helper((2006, 12, 24), "Second to last Sunday of 2006") + def test_week_0(self): + def check(value, format, *expected): + self.assertEqual(_strptime._strptime_time(value, format)[:-1], expected) + check('2015 0 0', '%Y %U %w', 2014, 12, 28, 0, 0, 0, 6, -3) + check('2015 0 0', '%Y %W %w', 2015, 1, 4, 0, 0, 0, 6, 4) + check('2015 0 1', '%Y %U %w', 2014, 12, 29, 0, 0, 0, 0, -2) + check('2015 0 1', '%Y %W %w', 2014, 12, 29, 0, 0, 0, 0, -2) + check('2015 0 2', '%Y %U %w', 2014, 12, 30, 0, 0, 0, 1, -1) + check('2015 0 2', '%Y %W %w', 2014, 12, 30, 0, 0, 0, 1, -1) + check('2015 0 3', '%Y %U %w', 2014, 12, 31, 0, 0, 0, 2, 0) + check('2015 0 3', '%Y %W %w', 2014, 12, 31, 0, 0, 0, 2, 0) + check('2015 0 4', '%Y %U %w', 2015, 1, 1, 0, 0, 0, 3, 1) + check('2015 0 4', '%Y %W %w', 2015, 1, 1, 0, 0, 0, 3, 1) + check('2015 0 5', '%Y %U %w', 2015, 1, 2, 0, 0, 0, 4, 2) + check('2015 0 5', '%Y %W %w', 2015, 1, 2, 0, 0, 0, 4, 2) + check('2015 0 6', '%Y %U %w', 2015, 1, 3, 0, 0, 0, 5, 3) + check('2015 0 6', '%Y %W %w', 2015, 1, 3, 0, 0, 0, 5, 3) + class CacheTests(unittest.TestCase): """Test that caching works properly.""" |