Azure / msrest-for-python

The runtime library "msrest" for AutoRest generated Python clients.
MIT License
41 stars 64 forks source link

Replace isodate #33

Open lmazuel opened 7 years ago

lmazuel commented 7 years ago

Following discussion with @zooba about isodate:

The features we use of isodate are:

Datetime is simple, and move from isodate is straightforward.

Duration is way more complicated, since this is relative duration (one month can't be converted to timedelta). Isodate algorithm returns timedelta instances for duration defined in days/hours/..., and a specific isodate.Duration class for ambiguous relative duration. It's dynamic based on what is parsed.

I found aniso8601 to parse duration. Aniso8601 is not using dynamic return type, there is a relative flag to decide if you want timedelta (might be converted with 1 month == 30 days), or dateutil.relativedelta to keep the precision. Aniso8601 does not serialize, but it's not the most complicated part.

Moving this dependency will also imply that users will get different object from a SDK call, moving from the couple timedelta/isodate.Duration to dateutil.relativedelta.

Considering that the issue itself (2to3 on Py3 install) is not that critical for now, and that there is no direct obvious solution, I plan to do nothing for now, but I keep this issue open for the record of what I found. Eventually we'll have to work on this.

FYI @johanste

smereczynski commented 6 years ago

It's really easy to fix isolate and maintain it. I did that months ago for the compatibility with Azure Functions in Py 3.6. https://github.com/smereczynski/isodate. Maybe it will be much easier to fork it and include?