myusuf3 / delorean

Delorean: Time Travel Made Easy
http://delorean.rtfd.org/
MIT License
1.84k stars 128 forks source link

Adds support for fractional units to next_/last_ week/day/hour/minute… #77

Closed liavkoren closed 6 years ago

liavkoren commented 8 years ago

…/second.

Re: issue #75, this appears to be related to https://github.com/dateutil/dateutil/issues/40 + https://github.com/myusuf3/delorean/blob/master/delorean/dates.py#L295. It looks like some sort of official relativedelta float-support for fractional years/months might be coming in the 2.5.0 release of dateutils. In the meantime, floats do work with relativedelta for weeks down to microseconds.

This patch adds support for those. If you think this is a worthwhile idea, I'm happy to write some tests for it.

Review on Reviewable

liavkoren commented 8 years ago

If we do implement fractional weeks..microseconds, we should probably handle the conversion for months and years, too. Having thought about this more, I start to see why dateutils didn't support floats for month/year.

Months and years are stupid.

myusuf3 commented 8 years ago

Thanks for the pull request. Adding some tests would help, make sure you verify that whole numbers continue to work and update the documentation accordingly.