Skip to content

Fiddle: update date parsing to use new python function by default#134

Merged
krishan711 merged 1 commit into
mainfrom
dates
May 7, 2026
Merged

Fiddle: update date parsing to use new python function by default#134
krishan711 merged 1 commit into
mainfrom
dates

Conversation

@krishan711
Copy link
Copy Markdown
Contributor

Description

Screenshots:

Checklist:

  • I have updated the CHANGELOG with a summary of my changes

Copilot AI review requested due to automatic review settings May 7, 2026 10:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates core.util.date_util.datetime_from_string to prefer Python’s ISO-8601 parsing (datetime.fromisoformat) and normalize parsed datetimes to UTC before falling back to the existing strptime-based parsing.

Changes:

  • Attempt to parse incoming datetime strings using datetime.datetime.fromisoformat first.
  • Normalize parsed datetimes to UTC (convert if timezone-aware; otherwise set UTC tzinfo).
  • Retain the existing strptime(..., dateFormat) fallback and DateConversionException on failure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/util/date_util.py
Comment on lines +32 to 37
try:
dt = datetime.datetime.fromisoformat(dateString)
return dt.astimezone(datetime.UTC) if dt.tzinfo is not None else dt.replace(tzinfo=datetime.UTC)
except (TypeError, ValueError):
pass
try:
Comment thread core/util/date_util.py
Comment on lines +32 to 38
try:
dt = datetime.datetime.fromisoformat(dateString)
return dt.astimezone(datetime.UTC) if dt.tzinfo is not None else dt.replace(tzinfo=datetime.UTC)
except (TypeError, ValueError):
pass
try:
dt = datetime.datetime.strptime(dateString, dateFormat).replace(tzinfo=datetime.UTC)
Comment thread core/util/date_util.py
Comment on lines +32 to +33
try:
dt = datetime.datetime.fromisoformat(dateString)
@krishan711 krishan711 merged commit fee3b0c into main May 7, 2026
8 checks passed
@krishan711 krishan711 deleted the dates branch May 7, 2026 10:30
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