Skip to content

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

Merged
justinmayer merged 2 commits into
getpelican:masterfrom
minchinweb:iso-dates
Jul 13, 2021
Merged

justinmayer merged 2 commits into
getpelican:masterfrom
minchinweb:iso-dates

Conversation

@minchinweb

Copy link
Copy Markdown
Contributor

Current behaviour:

>>> from pelican.utils import SafeDatetime
>>> from datetime import datetime
>>> "{a:%G}-{a:%V}-{a:%u}".format(a=SafeDatetime.now())
'%G-%V-%u'
>>> "{a:%G}-{a:%V}-{a:%u}".format(a=datetime.now())
'2021-27-7'

(%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

@avaris avaris left a comment

Copy link
Copy Markdown
Member

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
@justinmayer

Copy link
Copy Markdown
Member

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants