Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Get TimeDelta from Duration #133

Open
itsthejoker opened this issue Aug 7, 2023 · 1 comment
Open

Get TimeDelta from Duration #133

itsthejoker opened this issue Aug 7, 2023 · 1 comment

Comments

@itsthejoker
Copy link

itsthejoker commented Aug 7, 2023

  • 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?

@sebastianmika
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants