Fixes #1395: extends pelican.utils.strftime with - prefix to strip leading zeros

Adds the ability to use `-` prefix with C89 format codes to strip any
leading zeros.
This commit is contained in:
Deniz Turgut 2014-07-15 18:15:03 -04:00
commit 7c3cc8fc0d
3 changed files with 33 additions and 5 deletions

View file

@ -280,6 +280,13 @@ class TestUtils(LoggedTestCase):
self.assertEqual(utils.strftime(d, '%d/%m/%Y Øl trinken beim Besäufnis'),
'29/08/2012 Øl trinken beim Besäufnis')
# alternative formatting options
self.assertEqual(utils.strftime(d, '%-d/%-m/%y'), '29/8/12')
self.assertEqual(utils.strftime(d, '%-H:%-M:%-S'), '0:0:0')
d = utils.SafeDatetime(2012, 8, 9)
self.assertEqual(utils.strftime(d, '%-d/%-m/%y'), '9/8/12')
# test the output of utils.strftime in a different locale
# Turkish locale