I am wondering how to take a user-inputted string (i.e. 1 day, 5 hours, 15 minutes, 2 seconds
) and convert it to either a timedelta
object or (preferably) the number of seconds in that interval.
Note that:
- This is not a question about datetimes, it is about timedeltas. I don’t need “Tomorrow” or “In 5 minutes”, I need “1 day” or “5 minutes.”
- All fields are optional
- These are the possible fields:
year
,years
, ory
month
,months
, orm
week
,weeks
, orw
day
,days
, ord
hour
,hours
, orh
minute
,minutes
, orm
second
,seconds
, ors
- If you can get me started, I can probably do the rest
- The input can either be delimited by
,
or whitespace
Thank you!