What is TimeTuple in Python?


Many of Python's time functions handle time as a tuple of 9 numbers, as shown below −

IndexFieldValues
04-digit year2008
1Month1 to 12
2Day1 to 31
3Hour0 to 23
4Minute0 to 59
5Second0 to 61 (60 or 61 are leap-seconds)
6Day of Week0 to 6 (0 is Monday)
7Day of year1 to 366 (Julian day)
8Daylight savings-1, 0, 1, -1 means library determines DST

The above tuple is equivalent to struct_time structure. This structure has following attributes −

IndexAttributesValues
0tm_year2008
1tm_mon1 to 12
2tm_mday1 to 31
3tm_hour0 to 23
4tm_min0 to 59
5tm_sec0 to 61 (60 or 61 are leap-seconds)
6tm_wday0 to 6 (0 is Monday)
7tm_yday1 to 366 (Julian day)
8tm_isdst-1, 0, 1, -1 means library determines DST

Updated on: 28-Jan-2020

125 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements