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

Make date filter work on a RFC3339 string as well #959

Open
blfpd opened this issue Feb 28, 2025 · 0 comments
Open

Make date filter work on a RFC3339 string as well #959

blfpd opened this issue Feb 28, 2025 · 0 comments

Comments

@blfpd
Copy link

blfpd commented Feb 28, 2025

Add capability of the Tera filter {{ s | date }} to parse strings formatted as RFC 2822.

Example of RFC 2822 dates:

Fri, 25 Oct 2024 10:30:00 GMT
Fri, 25 Oct 2024 10:30:00 -0500
25 Oct 2024 10:30:00 +0200

Implementation

Hopefuly chrono supports it out of the box.

In the implementation, we can’t just test if the string contains a T as the timezone GMT is commonly used. So I added the T test at the second place. I tested a string that might be of format 2822 if it contains at least 3 spaces. If you find a better implementation, I open to suggetions.

Motivation

In Zola, when using load_data(url="https://anchor.fm/s/41f4a6b4/podcast/rss"), the dates are formatted as RFC 2822, instead of a more common format. I wanted to format them the way I intended.

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

1 participant