Would like to know if there is a function in python that can take partial information in a time tuple and return a time tuple with complete information. For example, as I am typing, the date is Thursday, Oct 18, 2012. This means the day of the year is 292 and the weekday number is 3. I would like to be able to do something like:
>>> part_tuple=2012,10,18,0,0,0,0,0,0
>>> complete_time_tuple=unknown_mod.unknown_func(part_tuple)
>>> complete_time_tuple
>>> (2012, 10, 18, 0, 0, 0, 292, 3, 0)
Alternatively, I would like to do:
>>> part_tuple=2012,0,0,0,0,0,292,0,0
>>> complete_time_tuple=unknown_mod.unknown_func(part_tuple)
and get complete_tuple back again. Code can certainly be written to do this, but I am guessing that it’s already buried in a python module — time, datetime, calendar, or something — somewhere. Thanks.
For your first question, you can use
datetime(which requires at least Y, M, D):And the second should be easy enough with: