From 332be6e5c8005f699a708568939d31dd85e9cffb Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Tue, 13 Jul 2021 01:35:22 -0600 Subject: [PATCH] Support date format codes G, V, and u (used by ISO dates) (#2902) --- pelican/tests/test_utils.py | 3 +++ pelican/utils.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index 10816199..5fbd066d 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -513,6 +513,9 @@ class TestUtils(LoggedTestCase): d = utils.SafeDatetime(2012, 8, 9) self.assertEqual(utils.strftime(d, '%-d/%-m/%y'), '9/8/12') + d = utils.SafeDatetime(2021, 1, 8) + self.assertEqual(utils.strftime(d, '%G - %-V - %u'), '2021 - 1 - 5') + # test the output of utils.strftime in a different locale # Turkish locale @unittest.skipUnless(locale_available('tr_TR.UTF-8') or diff --git a/pelican/utils.py b/pelican/utils.py index 8c3a886d..b69cbf95 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -50,7 +50,8 @@ def strftime(date, date_format): ''' def strip_zeros(x): return x.lstrip('0') or '0' - c89_directives = 'aAbBcdfHIjmMpSUwWxXyYzZ%' + # includes ISO date parameters added by Python 3.6 + c89_directives = 'aAbBcdfGHIjmMpSUuVwWxXyYzZ%' # grab candidate format options format_options = '%[-]?.'