Skip to content

Add support for timezone without colon (similar to datetime) #537

Closed

Description

@Olegt0rr

Description

Some APIs returns timezone without a colon symbol. Like this:

DT_STRING = "2023-08-25T20:32:38.696+0000"

It's not a problem for python's datetime:

datetime.fromisoformat(DT_STRING)
# 2023-08-25 20:32:38.696000+00:00

But it's a problem for msgspec:

class Issue(Struct):
    created_at: datetime

convert({"created_at": DT_STRING}, MyModel)
# msgspec.ValidationError: Invalid RFC3339 encoded datetime - at `$.created_at`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions