ctparse icon indicating copy to clipboard operation
ctparse copied to clipboard

Get TimeDelta from Duration

Open itsthejoker opened this issue 2 years ago • 1 comments

  • ctparse - Parse natural language time expressions in python version: 0.3.6
  • Python version: 3.11.1
  • Operating System: MacOS

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?

itsthejoker avatar Aug 07 '23 15:08 itsthejoker

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.

sebastianmika avatar Aug 07 '23 22:08 sebastianmika