On Thu, Jan 29, 2015 at 11:19 AM, Yawar Amin <email@example.com> wrote:My test implementation works for me on Python 2.7, see http://repl.it/9Wzcool site!And yes, it does appear to work.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.Another option would be to override just about everything...-ChrisNotice especially the last few assertions, where normal datetime objects are on the LHS.Regards,Yawar
On 2015-01-29, at 2:04, Chris Barker <firstname.lastname@example.org> wrote:On Wed, Jan 28, 2015 at 6:55 PM, Yawar Amin <email@example.com> wrote:Cool, the comparison operator logic looks very similar to mine:
Did you get it to work both ways? i.e.datetime.neg_inf < datetime.now()and
datetime.now() > datetime.neg_infI had trouble with that, because the regular datetime doesn't know how to compare itself to a neg_inf object.
I believe the ideal design is the following type hierarchy:
But in the interests of pragmatism, I think this one can be made to
datetime_pos_infyup -- should work.and you could add class methods to the datetime object, so you could do:datetime.neg_inf()anddatetime.pos_inf()Theadvantage to this is that we don't have to switch everything over to
using a new derived type--just use the normal datetime for the majority
of cases where we don't need inifinity dates.And it could be a third part package, too. -- particularly good for backward compatibility.-Chris
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception