Skip to content

parse_dt method that specifically returns a DateTime #917

@kerrickstaley

Description

@kerrickstaley
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

pdl.parse can return a Date, Time, Duration, or DateTime, depending on the args you pass to it. This is annoying in type-checked codebases, because you have to write

my_dt = pdl.parse(my_dt_string)
assert isinstance(my_dt, pdl.DateTime)

every time you want to parse a datetime string.

I wish there were a function parse_dt that was guaranteed to return a DateTime, and raises if you pass it something else like '2024-09-12T10:00:00Z/2024-09-12T15:30:00Z'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions