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

Support date format codes G, V, and u (used by ISO dates) #2902

merged 2 commits into from Jul 13, 2021


Copy link

Current behaviour:

>>> from pelican.utils import SafeDatetime
>>> from datetime import datetime
>>> "{a:%G}-{a:%V}-{a:%u}".format(
>>> "{a:%G}-{a:%V}-{a:%u}".format(

(%G gives you the ISO year, %V gives you the ISO week, and %u gives you the ISO day)

These codes aren't part of the C89 spec, but were added in Python 3.6 (which is the minimum officially supported version of Python for Pelican), so I don't expect any issues with supporting them.

(As a side, this also lead me to discover why %-d works in Pelican and nowhere else!)

Usecase: I want to create a weekly "period archive" and it would be simpliest to use the ISO dating, as that is already built into Python's standard library.

This also adds a test to make sure these are working as expected.

Pull Request Checklist

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools
  • Added tests for changed code
  • [ ? ] Updated documentation for changed code

Copy link

@avaris avaris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


MinchinWeb added a commit to MinchinWeb/minchin.pelican.readers.gpx that referenced this pull request Jul 12, 2021
Copy link

Thanks to @MinchinWeb for the enhancement and to @avaris for reviewing. 💫

@justinmayer justinmayer merged commit 332be6e into getpelican:master Jul 13, 2021
@MinchinWeb MinchinWeb deleted the iso-dates branch July 13, 2021 15:21
MinchinWeb added a commit to MinchinWeb/minchin.pelican.readers.gpx that referenced this pull request Jan 14, 2024
see getpelican/pelican#2902 merged into Pelican 4.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants