Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datetime helper breaks on Windows #23

Open
squiddy opened this issue May 18, 2012 · 2 comments
Open

datetime helper breaks on Windows #23

squiddy opened this issue May 18, 2012 · 2 comments

Comments

@squiddy
Copy link

squiddy commented May 18, 2012

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
@fwenzel
Copy link
Collaborator

fwenzel commented May 18, 2012

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

asfaltboy added a commit to asfaltboy/jingo that referenced this issue Jan 4, 2013
… with %d,

this is the least complicated method of doing things but will cause
inconsistent behavior across systems.

Anyone has another suggestion?
@jsocol
Copy link
Collaborator

jsocol commented Sep 21, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants