PyDocs

Generic Operating System Services

time

This module provides various functions to manipulate time values.

There are two standard representations of time.  One is the number
of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer
or a floating-point number (to represent fractions of seconds).
The epoch is the point where the time starts, the return value of time.gmtime(0).
It is January 1, 1970, 00:00:00 (UTC) on all platforms.

The other representation is a tuple of 9 integers giving local time.
The tuple items are:
  year (including century, e.g. 1998)
  month (1-12)
  day (1-31)
  hours (0-23)
  minutes (0-59)
  seconds (0-59)
  weekday (0-6, Monday is 0)
  Julian day (day in the year, 1-366)
  DST (Daylight Savings Time) flag (-1, 0 or 1)
If the DST flag is 0, the time is given in the regular time zone;
if it is 1, the time is given in the DST time zone;
if it is -1, mktime() should guess based on the date and time.
Symbols in time

a

altzone
The offset of the local DST timezone, in seconds west of UTC, if one is defined.
asctime
Convert a time tuple to a string, e.g.

c

CLOCK_BOOTTIME
Identical to CLOCK_MONOTONIC, except it also includes any time that the system is suspended.
clock_getres
Return the resolution (precision) of the specified clock clk_id.
clock_gettime
Return the time of the specified clock clk_id as a float.
clock_gettime_ns
Return the time of the specified clock clk_id as nanoseconds (int).
CLOCK_HIGHRES
The Solaris OS has a CLOCK_HIGHRES timer that attempts to use an optimal hardware source, and may give close to nanosecond resolution.
CLOCK_MONOTONIC
Clock that cannot be set and represents monotonic time since some unspecified starting point.
CLOCK_MONOTONIC_RAW
Similar to CLOCK_MONOTONIC, but provides access to a raw hardware-based time that is not subject to NTP adjustments.
CLOCK_MONOTONIC_RAW_APPROX
Similar to CLOCK_MONOTONIC_RAW, but reads a value cached by the system at context switch and hence has less accuracy.
CLOCK_PROCESS_CPUTIME_ID
High-resolution per-process timer from the CPU.
CLOCK_PROF
High-resolution per-process timer from the CPU.
CLOCK_REALTIME
Real-time clock.
clock_settime
Set the time of the specified clock clk_id.
clock_settime_ns
Set the time of the specified clock clk_id with nanoseconds.
CLOCK_TAI
International Atomic Time
CLOCK_THREAD_CPUTIME_ID
Thread-specific CPU-time clock.
CLOCK_UPTIME
Time whose absolute value is the time the system has been running and not suspended, providing accurate uptime measurement, both absolute and interval.
CLOCK_UPTIME_RAW
Clock that increments monotonically, tracking the time since an arbitrary point, unaffected by frequency or time adjustments and not incremented while the system is asleep.
CLOCK_UPTIME_RAW_APPROX
Like CLOCK_UPTIME_RAW, but the value is cached by the system at context switches and therefore has less accuracy.
ctime
Convert a time in seconds since the Epoch to a string in local time.

d

daylight
Nonzero if a DST timezone is defined.

g

get_clock_info
Get information of the specified clock.
gmtime
tm_sec, tm_wday, tm_yday, tm_isdst)

l

localtime
tm_sec,tm_wday,tm_yday,tm_isdst)

m

mktime
Convert a time tuple in local time to seconds since the Epoch.
monotonic
Monotonic clock, cannot go backward.
monotonic_ns
Monotonic clock, cannot go backward, as nanoseconds.

p

perf_counter
Performance counter for benchmarking.
perf_counter_ns
Performance counter for benchmarking as nanoseconds.
process_time
Process time for profiling: sum of the kernel and user-space CPU time.
process_time_ns
Process time for profiling as nanoseconds: sum of the kernel and user-space CPU time.
pthread_getcpuclockid
Return the clk_id of a thread's CPU time clock.

s

sleep
Delay execution for a given number of seconds.
strftime
Convert a time tuple to a string according to a format specification.
strptime
Parse a string to a time tuple according to a format specification.
struct_time
The time value as returned by gmtime(), localtime(), and strptime(), and accepted by asctime(), mktime() and strftime().

t

thread_time
Thread time for profiling: sum of the kernel and user-space CPU time.
thread_time_ns
Thread time for profiling as nanoseconds: sum of the kernel and user-space CPU time.
time
Return the current time in seconds since the Epoch.
time_ns
Return the current time in nanoseconds since the Epoch.
timezone
The offset of the local (non-DST) timezone, in seconds west of UTC (negative in most of Western Europe, positive in the US, zero in the UK).
tzname
A tuple of two strings: the first is the name of the local non-DST timezone, the second is the name of the local DST timezone.
tzset
Initialize, or reinitialize, the local timezone to the value stored in os.environ['TZ'].