Max M wrote: > # -*- coding: latin-1 -*- > > """ > > I am currently using the datetime package, but I find that the design > is oddly > asymmetric. I would like to know why. Or perhaps I have misunderstood > how it should be used?
Yes, you did. datetime.timetuple is those who want *time module* format, you should use datetime.data, datetime.time, datetime.year and so on... [snip a lot of timetuple wrestling] > The other way around is also easy. > >>>> dt = datetime(2005, 1, 1, 12, 0, 0) >>>> date(*dt.timetuple()[:3]) > datetime.date(2005, 1, 1) As they say, if the only tool you have is timetuple, everything looks like tuple <wink> Try this: >>> dt = datetime(2005, 1, 1, 12, 0, 0) >>> dt.date() datetime.date(2005, 1, 1) Serge. -- http://mail.python.org/mailman/listinfo/python-list