Skip to content
Discussion options

You must be logged in to vote

Hi!

You can find the answer to your question in the documentation here: https://typer.tiangolo.com/tutorial/parameter-types/datetime/#custom-date-format

In short, Typer allows you to specify the date formats that should be used instead of relying on the default ones.

You can edit your code to something like this:

def main(now: Optional[datetime.datetime] = typer.Option(..., formats=["%Y-%m-%dT%H:%M:%S%z"])):
    ...

With %z referring to the timezone offset (see here) and then it should be able to parse your input string.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@egeres
Comment options

Answer selected by svlandeg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants