time, calendar, datetime, etc
Andrew Dalke
adalke at mindspring.com
Mon Aug 4 14:40:01 EDT 2003
John Roth
> On the
> same token, though, it shouldn't get in the way of people who want to
> extend it to handle additional calendar types, or bring dates back before
> 1AD.
But it doesn't. I showed an easy way to derive from the datetime
class to support dates before 1AD, by doing an offset of 6,000 years.
class RothDate(object):
def __init__(self, year, month, day):
self._date = datetime.date(year + 6000, month, day)
year = property(lambda self: self._date.year - 6000)
month = property(lambda self: self._date.month)
day = property(lambda self: self._date.day)
def weekday(self): self._date.weekday
...
d = RothDate(-200, 2, 10)
print d.year, d.month. d.day
print d.weekday()
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list