[Python-Dev] ISO 8601 durations and datetime.timedelta
On Fri, Mar 28, 2014 at 1:13 PM, Skip Montanaro <skip at pobox.com> wrote:
> Given that the timedelta has more than "a month's" worth of days, how
> would you describe it using the ISO8601 duration notation without
> referencing a specific point in time? Conversely, given your example,
> "P3Y6M4DT12H30M5S", how would you convert that into a timedelta
> without knowing which exact years and months this duration refers to?
> Timedelta objects are very precise beasts, which is almost certainly
> why they don't support "years" and "months" args in their
So why would they need to support them in str()? We could make
str(timedelta(days=369, hours=12, minutes=30, seconds=5)) return
"P369DT12H30M5S", but that would hardly be an improvement over
>>> print timedelta(days=369, hours=12, minutes=30, seconds=5)
369 days, 12:30:05
and I don't think ISO 8601 allows for negative durations, so it gives
us little guidance for the other issue either.
My preference would be to leave strict ISO 8601 compliance to 3rd party
-------------- next part --------------
An HTML attachment was scrubbed...