ISO to Gregorian, strptime madness

Afanasiy abelikov72 at hotmail.com
Thu Dec 4 10:14:11 EST 2003


Can I easily convert from ISO to Gregorian calendars in Python 2.3?

For example, what Gregorian date is year 2004, week 1, day 1?

If possible, I'd greatly prefer to do this with the standard library.
I believe the mx.DateTime module provides this functionality, but I've
spent a bit of time converting pre-2.3 code to the new datetime modules.

---

While I'm posting, how about this old dilemma... from the 2.3 modules.
strptime exists in time, but not in datetime, while strftime exists in
both. So, to strptime into a datetime, I am forced to use * like so :

  t1tmp = time.strptime(sometext,timeformat)
  t1 = datetime.datetime(*t1tmp[0:6])      

My question is, is there a better way which might be closer to something
like datetime.strptime? (which doesn't exist strangely).

---

-AB




More information about the Python-list mailing list