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

Relaxed datetime/time parsing #539

Merged
merged 1 commit into from
Aug 26, 2023
Merged

Relaxed datetime/time parsing #539

merged 1 commit into from
Aug 26, 2023

Conversation

jcrist
Copy link
Owner

@jcrist jcrist commented Aug 26, 2023

Previously we strictly followed the RFC3339 format when parsing datetime and time objects from strings. We now support a few common ISO8601 compatible relaxations:

  • A : isn't required as part of the timezone component in both datetime and time strings (2022-01-02T03:04:05.678+0102 and 2022-01-02T03:04:05.678+01:02 are treated the same).

  • A may be used instead of T/t as a separator between date and time components when parsing datetime strings (2022-01-02 03:04:05.678+01:02 and 2022-01-02T03:04:05.678+01:02 are treated the same).

When encoding datetime/time objects we still strictly follow RFC3339. This eases integrating msgspec with other systems that don't strictly follow RFC3339.

Fixes #537.

Previously we strictly followed the RFC3339 format when parsing datetime
and time objects from strings. We now support a few common ISO8601
compatible relaxations:

- A `:` isn't required as part of the timezone component in both
  datetime and time strings (`2022-01-02T03:04:05.678+0102` and
  `2022-01-02T03:04:05.678+01:02` are treated the same).

- A ` ` may be used instead of `T`/`t` as a separator between date and
  time components when parsing datetime strings.

When encoding datetime/time objects we still strictly follow RFC3339.
This eases integrating msgspec with other systems that don't strictly
follow RFC3339.
@jcrist jcrist merged commit d95b33c into main Aug 26, 2023
7 checks passed
@jcrist jcrist deleted the relax-datetime-time-parsing branch August 26, 2023 20:25
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.

Add support for timezone without colon (similar to datetime)
1 participant