Closed BenjaminAfrolabs closed 1 year ago
what happened here is that ctparse doesn't support combining duration (as of yet), so it will just return one of the (both incorrect) matches.
one of the issue with these "combined espressions" is how to represent them, right now the representation is:
duration = value + unit
so that 1h and 30 minutes can't be represented, but it could be represented as 90 minutes.
I guess the best solution would be to:
timedelta
does)Durations are not working very well for a bunch of reason but we'd like to work on it soon, I apologize but I can't give you an ETA right now
No worries on the ETA since I can get it working with the array from the debug flag and convert it into python's timedelta doing this (it does break if I add *seconds though):
duration_params = {}
for t in ctparse(duration, debug=True):
duration_params[t.resolution.unit.value] = t.resolution.value
duration = timedelta(**duration_params)
Combined expressions might also be logical to be returned as a list
Added a simple solution in #129 - closing this for now
Description
When calling
ctparse("1 hour and 42 minutes")
I expected to get a duration containing 1 hours and 42 minutes and I got back just the 42 minutes.What I Did
Enabled debug and I got 2 duration objects, the first the hour the second the minutes