A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20090416/89ad3dba/attachment.htm below:

<div>Hi Jess,</div><div><br></div><div>I&#39;m sorry if I&#39;m failing to understand the use of this function from not looking closely at your code. I&#39;m a bit dubious about the usefulness of this (I&#39;m not sure I understand the use cases), but I&#39;m very open to being convinced. Datetime semantics are very important in some areas -- I use them a lot.</div>
<div><br></div><div>I&#39;m not convinced the semantics of monthdelta are obvious.</div><div><br></div>A month doesn&#39;t have a consistent length -- it could be 28, 29, 30 or 31 days.<br><div><br></div><div>What happens when you ask for the date in &quot;1 month&#39;s&quot; time on the 31st Jan? What date is a month after the 31st Jan?  </div>
<div><br></div><div>Do you have a good spec (er, I mean PEP) for this describing what happens in the edge cases and what is meant by a monthdelta? The bug notes say it &quot;deals sensibly&quot; with these issues, but that&#39;s really not enough to understand what the function is likely to do. At the very least, a few well-chosen examples would help to illustrate the functionality much more clearly.</div>
<div><br></div><div>Cheers,</div><div>-Tennessee</div><div><br><br><div class="gmail_quote">On Thu, Apr 16, 2009 at 4:18 PM, Jess Austin <span dir="ltr">&lt;<a href="mailto:jess.austin@gmail.com">jess.austin@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">hi,<br>
<br>
I&#39;m new to python core development, and I&#39;ve been advised to write to<br>
python-dev concerning a feature/patch I&#39;ve placed at<br>
<a href="http://bugs.python.org/issue5434" target="_blank">http://bugs.python.org/issue5434</a>, with Rietveld at<br>
<a href="http://codereview.appspot.com/25079" target="_blank">http://codereview.appspot.com/25079</a>.<br>
<br>
This patch adds a &quot;monthdelta&quot; class and a &quot;monthmod&quot; function to the<br>
datetime module.  The monthdelta class is much like the existing<br>
timedelta class, except that it represents months offset from a date,<br>
rather than an exact period offset from a date.  This allows us to<br>
easily say, e.g. &quot;3 months from now&quot; without worrying about the number<br>
of days in the intervening months.<br>
<br>
    &gt;&gt;&gt; date(2008, 1, 30) + monthdelta(1)<br>
    datetime.date(2008, 2, 29)<br>
    &gt;&gt;&gt; date(2008, 1, 30) + monthdelta(2)<br>
    datetime.date(2008, 3, 30)<br>
<br>
The monthmod function, named in (imperfect) analogy to divmod, allows<br>
us to round-trip by returning the interim between two dates<br>
represented as a (monthdelta, timedelta) tuple:<br>
<br>
    &gt;&gt;&gt; monthmod(date(2008, 1, 14), date(2009, 4, 2))<br>
    (datetime.monthdelta(14), datetime.timedelta(19))<br>
<br>
Invariant: dt + monthmod(dt, dt+td)[0] + monthmod(dt, dt+td)[1] == dt + td<br>
<br>
These also work with datetimes!  There are more details in the<br>
documentation included in the patch.  In addition to the C module<br>
file, I&#39;ve updated the datetime CAPI, the documentation, and tests.<br>
<br>
I feel this would be a good addition to core python.  In my work, I&#39;ve<br>
often ended up writing annoying one-off &quot;add-a-month&quot; or similar<br>
functions.  I think since months work differently than most other time<br>
periods, a new object is justified rather than trying to shoe-horn<br>
something like this into timedelta.  I also think that the round-trip<br>
functionality provided by monthmod is important to ensure that<br>
monthdeltas are &quot;first-class&quot; objects.<br>
<br>
Please let me know what you think of the idea and/or its execution.<br>
<br>
thanks,<br>
<font color="#888888">Jess Austin<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/tleeuwenburg%40gmail.com" target="_blank">http://mail.python.org/mailman/options/python-dev/tleeuwenburg%40gmail.com</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>--------------------------------------------------<br>Tennessee Leeuwenburg<br><a href="http://myownhat.blogspot.com/">http://myownhat.blogspot.com/</a><br>&quot;Don&#39;t believe everything you think&quot;<br>

</div>



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4