Issue 5434: datetime.monthdelta - Python tracker (original) (raw)

Created on 2009-03-07 05:04 by jess.austin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
monthdelta.py jess.austin,2009-03-11 21:39 prototype implementation in python
monthdelta3.diff jess.austin,2009-04-23 04:32 unified patch on py3k
Messages (10)
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) * (Python committer) 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) * (Python committer) 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
History
Date User Action Args
2022-04-11 14:56:46 admin set github: 49684
2011-01-10 23:35:14 adamnelson set nosy: + adamnelsonmessages: +
2010-06-02 18:14:41 belopolsky set status: pending -> closedmessages: + stage: resolved
2010-06-01 19:08:26 jess.austin set status: open -> pending
2010-06-01 16:40:16 jess.austin set status: pending -> openmessages: +
2010-05-26 00:22:22 belopolsky set status: open -> pendingnosy: + belopolskymessages: + assignee: belopolskyresolution: rejected
2009-04-23 04:34:47 jess.austin set files: - monthdelta2.diff
2009-04-23 04:33:29 jess.austin set files: + monthdelta3.diff
2009-04-22 20:02:09 jess.austin set messages: +
2009-04-21 19:02:43 cvrebert set nosy: + cvrebert
2009-04-16 05:38:21 jess.austin set files: - monthdelta.diff
2009-04-16 05:37:30 jess.austin set files: + monthdelta2.diff
2009-03-24 20:33:05 jess.austin set messages: + title: datetime.MonthDelta -> datetime.monthdelta
2009-03-12 20:56:18 jess.austin set files: - datetimemodule.diff
2009-03-12 20:54:51 jess.austin set files: + monthdelta.diff
2009-03-11 21:39:44 jess.austin set files: + monthdelta.pymessages: +
2009-03-07 10:25:05 pitrou set nosy: + lemburg, tim.peters
2009-03-07 05:59:38 jess.austin set messages: +
2009-03-07 05:24:46 jess.austin set files: + datetimemodule.diffkeywords: + patchmessages: +
2009-03-07 05:04:48 jess.austin create