| 1 |
|
| 2 |
|
| 3 |
from _structseq import structseqtype, structseqfield, SimpleNamespace |
| 4 |
import time |
| 5 |
|
| 6 |
class struct_time(metaclass=structseqtype): |
| 7 |
__module__ = 'time' |
| 8 |
name = 'time.struct_time' |
| 9 |
|
| 10 |
tm_year = structseqfield(0, "year, for example, 1993") |
| 11 |
tm_mon = structseqfield(1, "month of year, range [1, 12]") |
| 12 |
tm_mday = structseqfield(2, "day of month, range [1, 31]") |
| 13 |
tm_hour = structseqfield(3, "hours, range [0, 23]") |
| 14 |
tm_min = structseqfield(4, "minutes, range [0, 59]") |
| 15 |
tm_sec = structseqfield(5, "seconds, range [0, 61])") |
| 16 |
tm_wday = structseqfield(6, "day of week, range [0, 6], Monday is 0") |
| 17 |
tm_yday = structseqfield(7, "day of year, range [1, 366]") |
| 18 |
tm_isdst = structseqfield(8, "1 if summer time is in effect, 0 if not" |
| 19 |
", and -1 if unknown") |
| 20 |
|
| 21 |
|
| 22 |
tm_zone = structseqfield(10, "abbreviation of timezone name") |
| 23 |
tm_gmtoff = structseqfield(12,"offset from UTC in seconds") |
| 24 |
|
| 25 |
|
| 26 |
def strptime(string, format="%a %b %d %H:%M:%S %Y"): |
| 27 |
"""strptime(string, format) -> struct_time |
| 28 |
|
| 29 |
Parse a string to a time tuple according to a format specification. |
| 30 |
See the library reference manual for formatting codes |
| 31 |
(same as strftime()).""" |
| 32 |
|
| 33 |
import _strptime |
| 34 |
return _strptime._strptime_time(string, format) |
| 35 |
|
| 36 |
def get_clock_info(name): |
| 37 |
info = SimpleNamespace() |
| 38 |
info.implementation = "" |
| 39 |
info.monotonic = 0 |
| 40 |
info.adjustable = 0 |
| 41 |
info.resolution = 1.0 |
| 42 |
|
| 43 |
time._get_time_info(name, info) |
| 44 |
return info |
| 45 |
|
| 46 |
__doc__ = """This module provides various functions to manipulate time values. |
| 47 |
|
| 48 |
There are two standard representations of time. One is the number |
| 49 |
of seconds since the Epoch, in UTC (a.k.a. GMT). It may be an integer |
| 50 |
or a floating point number (to represent fractions of seconds). |
| 51 |
The Epoch is system-defined; on Unix, it is generally January 1st, 1970. |
| 52 |
The actual value can be retrieved by calling gmtime(0). |
| 53 |
|
| 54 |
The other representation is a tuple of 9 integers giving local time. |
| 55 |
The tuple items are: |
| 56 |
year (four digits, e.g. 1998) |
| 57 |
month (1-12) |
| 58 |
day (1-31) |
| 59 |
hours (0-23) |
| 60 |
minutes (0-59) |
| 61 |
seconds (0-59) |
| 62 |
weekday (0-6, Monday is 0) |
| 63 |
Julian day (day in the year, 1-366) |
| 64 |
DST (Daylight Savings Time) flag (-1, 0 or 1) |
| 65 |
If the DST flag is 0, the time is given in the regular time zone; |
| 66 |
if it is 1, the time is given in the DST time zone; |
| 67 |
if it is -1, mktime() should guess based on the date and time. |
| 68 |
|
| 69 |
Variables: |
| 70 |
|
| 71 |
timezone -- difference in seconds between UTC and local standard time |
| 72 |
altzone -- difference in seconds between UTC and local DST time |
| 73 |
daylight -- whether local time should reflect DST |
| 74 |
tzname -- tuple of (standard time zone name, DST time zone name) |
| 75 |
|
| 76 |
Functions: |
| 77 |
|
| 78 |
time() -- return current time in seconds since the Epoch as a float |
| 79 |
clock() -- return CPU time since process start as a float |
| 80 |
sleep() -- delay for a number of seconds given as a float |
| 81 |
gmtime() -- convert seconds since Epoch to UTC tuple |
| 82 |
localtime() -- convert seconds since Epoch to local time tuple |
| 83 |
asctime() -- convert time tuple to string |
| 84 |
ctime() -- convert time in seconds to string |
| 85 |
mktime() -- convert local time tuple to seconds since Epoch |
| 86 |
strftime() -- convert time tuple to string according to format specification |
| 87 |
strptime() -- parse string to time tuple according to format specification |
| 88 |
tzset() -- change the local timezone""" |
| 89 |
|