[Python-Dev] dateutil (original) (raw)

Robert Brewer fumanchu at amor.org
Fri Mar 12 11:08:04 EST 2004


Brett C. wrote:

Responding to both Tim's and Gustavo's follow-ups to my email here. 8 Personally I would love for datetime objects to have a class method to be able to take in the appropriate ISO-formatted date/time string and return the appropriate datetime object. Otherwise I would rather keep the interface clean of string parsing short of using strptime .

I use:

def datefromiso(isoString, todayOnError=True): try: args = tuple(map(int, isoString.split(u'-'))) return datetime.date(*args) except (TypeError, ValueError), x: if todayOnError: return datetime.date.today() else: raise x

def timefromiso(isoString, zeroOnError=True): try: args = tuple(map(int, isoString.split(u':'))) return datetime.time(*args) except (TypeError, ValueError), x: if zeroOnError: return datetime.time(0) else: raise x

> * Computing of Easter Sunday dates for any given year, > using Western, Orthodox or Julian algorithms;

Don't really see the use in this other than the rule figuring this out is odd enough that I never remember. Who really cares when Easter is beyond certain religious groups?

Lots of schools still structure Spring Break around Easter...since my org works with youth to a large extent, that means we do about 1/8 of our business for the year during Palm Sunday week and Easter week. Just an example.

Robert Brewer MIS Amor Ministries fumanchu at amor.org



More information about the Python-Dev mailing list