I wish to get the total duration of a relativedelta in terms of days.
Expected:
dateutil.timedelta(1 month, 24 days) -> dateutil.timedelta(55 days)
What I tried:
dateutil.timedelta(1 month, 24 days).days -> 24 (WRONG)
Is there a simple way to do this? Thanks!
This one bothered me as well. There isn't a very clean way to get the span of time in a particular unit. This is partly because of the date-range dependency on units.
relativedelta()takes an argument for months. But when you think about how long a month is, the answer is "it depends". With that said, it's technically impossible to convert arelativedelta()directly to days, without knowing which days the delta lands on.Here is what I ended up doing.