msg83272 - (view) |
Author: Jess Austin (jess.austin) |
Date: 2009-03-07 05:04 |
datetime is a wonderful module. Perhaps the only inconvenient aspect of using it is dealing with month calculations and comparisons. This patch adds a simple class, monthdelta, which represents date offsets in terms of months. It supports basic integer-like arithmetic, and also it may be added to dates and datetimes. It deals sensibly with leap-year and month-length issues. Also provided is a function, monthmod (named by imperfect analogy to divmod), which allows round-tripping: that is, taking 2 dates and returning a (monthdelta, timedelta) tuple that represents the interim between the dates. Note: I have named the class "monthdelta", but in light of recent python-dev discussions I should probably rename this to "MonthDelta". |
|
|
msg83273 - (view) |
Author: Jess Austin (jess.austin) |
Date: 2009-03-07 05:24 |
This is my first try at a patch. All functionality, tests, and documentation are included, but I won't be surprised if I need to make some changes! Please let me know. |
|
|
msg83275 - (view) |
Author: Jess Austin (jess.austin) |
Date: 2009-03-07 05:59 |
Rietveld link: http://codereview.appspot.com/25079 |
|
|
msg83480 - (view) |
Author: Jess Austin (jess.austin) |
Date: 2009-03-11 21:39 |
This prototype python implementation passes the same tests that the C implementation in the patch does (modulo import differences). I'll probably backport this for 2.x versions. |
|
|
msg84114 - (view) |
Author: Jess Austin (jess.austin) |
Date: 2009-03-24 20:33 |
With the rejection of Issue 5530, it seems best for the name of this class to remain lowercase. Mixing casing schemes within the same module would be perverse. |
|
|
msg86323 - (view) |
Author: Jess Austin (jess.austin) |
Date: 2009-04-22 20:02 |
The backport through python 2.3 is up at PyPI: http://pypi.python.org/pypi?name=MonthDelta&:action=display Download source and install, or just easy_install. Documentation is also linked at PyPI. |
|
|
msg106495 - (view) |
Author: Alexander Belopolsky (belopolsky) *  |
Date: 2010-05-26 00:22 |
MonthDelta has been published on PyPI and there was no activity on this issue since then. I conclude that there is little support for including this in stdlib. I am marking this as "rejected" and setting the status to pending. I will close this issue in a few weeks unless I hear objections. Jess, I see that your package is healthy on PyPI with over 700 downloads for the latest version. Note that some additional operations have been added recently to timedelta object and more are in the works. You may want to consider adding them to the next version of your package. (See issue 1289118 and issue 2706.) |
|
|
msg106846 - (view) |
Author: Jess Austin (jess.austin) |
Date: 2010-06-01 16:40 |
Yeah, the masses have spoken, and their silence is deafening. I was going to downplay the "health" of the package based on the number of downloads, but then I looked at the "futures" page. b^) Seriously, getting this in would require a core developer wanting it in, and at this point it seems none do. On the subject of float operations, while there may be some question about the integerness or floatness of timedelta, monthdelta is definitely an integer. As monthdelta already supports multiplication by integers and floor division by integers or monthdeltas, I don't see anything missing. To use monthdeltas with floats is to miss the point entirely. |
|
|
msg106906 - (view) |
Author: Alexander Belopolsky (belopolsky) *  |
Date: 2010-06-02 18:14 |
Rejecting this for stdlib. A 3rd party package is available at http://pypi.python.org/pypi?name=MonthDelta&:action=display . |
|
|
msg125955 - (view) |
Author: AdamN (adamnelson) |
Date: 2011-01-10 23:35 |
For future reference, python-dateutil seems like the maintained way to deal with "human" dates outside of the stdlib. http://pypi.python.org/pypi/python-dateutil |
|
|