jingo icon indicating copy to clipboard operation
jingo copied to clipboard

datetime helper breaks on Windows

Open squiddy opened this issue 13 years ago • 2 comments

Another developer had a problem with our project and we tracked it down to jingo's datetime filter.

The default format string is %B %e, %Y. It uses %e which is not available on all platforms (according to this list in the Python documentation). I guess replacing that by %d should be enough (although that adds a leading zero).

import datetime; x = datetime.datetime(2012, 12, 3, 12, 1, 34); x.strftime('%e') raises a ValueError exception, invalid format string.

>>> print platform.platform()
Windows-XP-5.1.2600-SP3

squiddy avatar May 18 '12 11:05 squiddy

Hm you could submit a pull request and use a different format string if platform.system() is Windows?

fwenzel avatar May 18 '12 17:05 fwenzel

Going through old issues, I realized that I have no idea where %e came from in the first place. It's not in the Python docs. It's from strftime(3) on linux, and all it does is print a space-padded day instead of a zero-padded day (e.g. May 3, 2015 vs May 3, 2015 with %-d vs May 03, 2015 with %d).

Rather than platform/system branching, let's just use %-d, an actually documented python thing. I'll do that soon.

jsocol avatar Sep 21 '15 18:09 jsocol