comtravo / ctparse

Parse natural language time expressions in python
https://www.comtravo.com
MIT License
131 stars 23 forks source link

Get TimeDelta from Duration #133

Open itsthejoker opened 1 year ago

itsthejoker commented 1 year ago

Description

What is the easiest / best way to convert a timedelta object from a Duration object? I want to go from the string "in two days" to a timedelta -> datetime, but the only thing I can think of is to manually try to match up the ctparse enums and fill out the timedelta myself. Is that the best way or is there something I'm missing?

sebastianmika commented 1 year ago

I am afraid you are right: you have to code that yourself. Duration does not have a build-in property to turn it into a timedelta. Likely somethings that would make sense to add.