<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Chris, agreed, it's not great to have years, months and dates inside the infinity datetimes. That's why ideally datetime, datetime_neg_inf and datetime_pos_inf should have been sibling types deriving from datetime_base.</div><div><br></div><div>I'll try to explore making this change in the stdlib ad seeing if that breaks th vs really badly.</div><div><br>On 2015-01-29, at 14:35, Chris Barker <<a href="mailto:chris.barker@noaa.gov">chris.barker@noaa.gov</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 29, 2015 at 11:19 AM, Yawar Amin <span dir="ltr"><<a href="mailto:yawar.amin@gmail.com" target="_blank">yawar.amin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>My test implementation works for me on Python 2.7, see <a href="http://repl.it/9Wz" target="_blank">http://repl.it/9Wz</a></div></div></blockquote><div><br></div><div>cool site! </div><div><br></div><div>And yes, it does appear to work.</div><div><br></div><div>However the subclassing approach is really weird, as the infinite datetimes have a year, month, day, etc -- that strikes me as ripe for error. That's why I didn't subclass, but just had them e independent.</div><div><br></div><div>Another option would be to override just about everything...</div><div><br></div><div>-Chris</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>Notice especially the last few assertions, where normal datetime objects are on the LHS.</div><div><br></div><div>Regards,</div><div><br></div><div>Yawar</div><div><div class="h5"><div><br>On 2015-01-29, at 2:04, Chris Barker <<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">On Wed, Jan 28, 2015 at 6:55 PM, Yawar Amin <span dir="ltr"><<a href="mailto:yawar.amin@gmail.com" target="_blank">yawar.amin@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Cool, the comparison operator logic looks very similar to mine:<br>
<br>
<a href="https://groups.google.com/d/msg/python-ideas/G3jeWoa6h14/ELpDLFu28QcJ" target="_blank">https://groups.google.com/d/msg/python-ideas/G3jeWoa6h14/ELpDLFu28QcJ</a><br>
<br></blockquote><div><br>Did you get it to work both ways? i.e.<br><br></div><div>datetime.neg_inf < datetime.now()<br></div><div><br></div><div>and <br> <br>datetime.now() > datetime.neg_inf <br><br></div><div>I had trouble with that, because the regular datetime doesn't know how to compare itself to a neg_inf object.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I believe the ideal design is the following type hierarchy:<br>
<br>
    datetime_base<br>
      datetime_neg_inf<br>
      datetime_pos_inf<br>
      datetime<br>
<br>
But in the interests of pragmatism, I think this one can be made to<br>
work:<br>
<br>
    datetime<br>
      datetime_neg_inf<br>
      datetime_pos_inf<br></blockquote><div><br></div><div>yup -- should work.<br><br></div><div>and you could add class methods to the datetime object, so you could do:<br><br></div><div>datetime.neg_inf()<br></div><div>and<br></div><div>datetime.pos_inf()<br></div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>The<br></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
advantage to this is that we don't have to switch everything over to<br>
using a new derived type--just use the normal datetime for the majority<br>
of cases where we don't need inifinity dates.<br></blockquote><div><br></div><div>And it could be a third part package, too. -- particularly good for backward compatibility.<br><br></div><div>-Chris<br></div><br clear="all"></div><br>-- <br><div><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            <a href="tel:%28206%29%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a>   voice<br>7600 Sand Point Way NE   <a href="tel:%28206%29%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a>   fax<br>Seattle, WA  98115       <a href="tel:%28206%29%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a>   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>
</div></blockquote></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>
</div></blockquote></body></html>