Skip to content

Update datetime filter to handle timezone info#561

Merged
computron merged 2 commits intomaterialsproject:mainfrom
wuz75:tz_fix
Mar 5, 2026
Merged

Update datetime filter to handle timezone info#561
computron merged 2 commits intomaterialsproject:mainfrom
wuz75:tz_fix

Conversation

@wuz75
Copy link
Copy Markdown
Contributor

@wuz75 wuz75 commented Dec 15, 2025

Pull Request Description

Problem:
This pull request fixes a ValueError encountered while parsing datetime strings in the Flask app. The error occurred because the datetime format did not account for timezone information (+00:00).

Fix:
Added the %z format specifier in the datetime.strptime method to handle the timezone offset correctly.

Changes:
Updated the code in app.py from:

date = dt.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f")

to:

date = dt.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z")

also added backwards compatibility with try/except.

added %z to handle +00:00 time zone error when parsing
Added error handling for date parsing to support backwards compatibility.
@wuz75
Copy link
Copy Markdown
Contributor Author

wuz75 commented Feb 12, 2026

@computron
could you please look at this? the latest pipy version of fireworks still has this bug.

@computron computron merged commit 48bf819 into materialsproject:main Mar 5, 2026
2 checks passed
@computron
Copy link
Copy Markdown
Member

Thanks!

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.

2 participants