1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module time</title>
<meta charset="utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>time</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/time.so">/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/time.so</a><br><a href="http://docs.python.org/library/time">Module Docs</a></font></td></tr></table>
<p><tt>This module provides various functions to manipulate time values.<br>
<br>
There are two standard representations of time. One is the number<br>
of seconds since the Epoch, in UTC (a.k.a. GMT). It may be an integer<br>
or a floating point number (to represent fractions of seconds).<br>
The Epoch is system-defined; on Unix, it is generally January 1st, 1970.<br>
The actual value can be retrieved by calling <a href="#-gmtime">gmtime</a>(0).<br>
<br>
The other representation is a tuple of 9 integers giving local time.<br>
The tuple items are:<br>
year (four digits, e.g. 1998)<br>
month (1-12)<br>
day (1-31)<br>
hours (0-23)<br>
minutes (0-59)<br>
seconds (0-59)<br>
weekday (0-6, Monday is 0)<br>
Julian day (day in the year, 1-366)<br>
DST (Daylight Savings Time) flag (-1, 0 or 1)<br>
If the DST flag is 0, the time is given in the regular time zone;<br>
if it is 1, the time is given in the DST time zone;<br>
if it is -1, <a href="#-mktime">mktime</a>() should guess based on the date and time.<br>
<br>
Variables:<br>
<br>
timezone -- difference in seconds between UTC and local standard time<br>
altzone -- difference in seconds between UTC and local DST time<br>
daylight -- whether local time should reflect DST<br>
tzname -- tuple of (standard time zone name, DST time zone name)<br>
<br>
Functions:<br>
<br>
<a href="#-time">time</a>() -- return current time in seconds since the Epoch as a float<br>
<a href="#-clock">clock</a>() -- return CPU time since process start as a float<br>
<a href="#-sleep">sleep</a>() -- delay for a number of seconds given as a float<br>
<a href="#-gmtime">gmtime</a>() -- convert seconds since Epoch to UTC tuple<br>
<a href="#-localtime">localtime</a>() -- convert seconds since Epoch to local time tuple<br>
<a href="#-asctime">asctime</a>() -- convert time tuple to string<br>
<a href="#-ctime">ctime</a>() -- convert time in seconds to string<br>
<a href="#-mktime">mktime</a>() -- convert local time tuple to seconds since Epoch<br>
<a href="#-strftime">strftime</a>() -- convert time tuple to string according to format specification<br>
<a href="#-strptime">strptime</a>() -- parse string to time tuple according to format specification<br>
<a href="#-tzset">tzset</a>() -- change the local timezone</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="time.html#struct_time">struct_time</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="struct_time">class <strong>struct_time</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>The time value as returned by <a href="#-gmtime">gmtime</a>(), <a href="#-localtime">localtime</a>(), and <a href="#-strptime">strptime</a>(), and<br>
accepted by <a href="#-asctime">asctime</a>(), <a href="#-mktime">mktime</a>() and <a href="#-strftime">strftime</a>(). May be considered as a<br>
sequence of 9 integers.<br>
<br>
Note that several fields' values are not the same as those defined by<br>
the C language standard for struct tm. For example, the value of the<br>
field tm_year is the actual year, not year - 1900. See individual<br>
fields' descriptions for details.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="struct_time-__add__"><strong>__add__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__add__">__add__</a>(y) <==> x+y</tt></dd></dl>
<dl><dt><a name="struct_time-__contains__"><strong>__contains__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__contains__">__contains__</a>(y) <==> y in x</tt></dd></dl>
<dl><dt><a name="struct_time-__eq__"><strong>__eq__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__eq__">__eq__</a>(y) <==> x==y</tt></dd></dl>
<dl><dt><a name="struct_time-__ge__"><strong>__ge__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__ge__">__ge__</a>(y) <==> x>=y</tt></dd></dl>
<dl><dt><a name="struct_time-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl>
<dl><dt><a name="struct_time-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__getslice__">__getslice__</a>(i, j) <==> x[i:j]<br>
<br>
Use of negative indices is not supported.</tt></dd></dl>
<dl><dt><a name="struct_time-__gt__"><strong>__gt__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__gt__">__gt__</a>(y) <==> x>y</tt></dd></dl>
<dl><dt><a name="struct_time-__hash__"><strong>__hash__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__hash__">__hash__</a>() <==> hash(x)</tt></dd></dl>
<dl><dt><a name="struct_time-__le__"><strong>__le__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__le__">__le__</a>(y) <==> x<=y</tt></dd></dl>
<dl><dt><a name="struct_time-__len__"><strong>__len__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__len__">__len__</a>() <==> len(x)</tt></dd></dl>
<dl><dt><a name="struct_time-__lt__"><strong>__lt__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__lt__">__lt__</a>(y) <==> x<y</tt></dd></dl>
<dl><dt><a name="struct_time-__mul__"><strong>__mul__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__mul__">__mul__</a>(n) <==> x*n</tt></dd></dl>
<dl><dt><a name="struct_time-__ne__"><strong>__ne__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__ne__">__ne__</a>(y) <==> x!=y</tt></dd></dl>
<dl><dt><a name="struct_time-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>
<dl><dt><a name="struct_time-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl>
<dl><dt><a name="struct_time-__rmul__"><strong>__rmul__</strong></a>(...)</dt><dd><tt>x.<a href="#struct_time-__rmul__">__rmul__</a>(n) <==> n*x</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>tm_hour</strong></dt>
<dd><tt>hours, range [0, 23]</tt></dd>
</dl>
<dl><dt><strong>tm_isdst</strong></dt>
<dd><tt>1 if summer time is in effect, 0 if not, and -1 if unknown</tt></dd>
</dl>
<dl><dt><strong>tm_mday</strong></dt>
<dd><tt>day of month, range [1, 31]</tt></dd>
</dl>
<dl><dt><strong>tm_min</strong></dt>
<dd><tt>minutes, range [0, 59]</tt></dd>
</dl>
<dl><dt><strong>tm_mon</strong></dt>
<dd><tt>month of year, range [1, 12]</tt></dd>
</dl>
<dl><dt><strong>tm_sec</strong></dt>
<dd><tt>seconds, range [0, 61])</tt></dd>
</dl>
<dl><dt><strong>tm_wday</strong></dt>
<dd><tt>day of week, range [0, 6], Monday is 0</tt></dd>
</dl>
<dl><dt><strong>tm_yday</strong></dt>
<dd><tt>day of year, range [1, 366]</tt></dd>
</dl>
<dl><dt><strong>tm_year</strong></dt>
<dd><tt>year, for example, 1993</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object><dd><tt>T.<a href="#struct_time-__new__">__new__</a>(S, ...) -> a new <a href="__builtin__.html#object">object</a> with type S, a subtype of T</tt></dl>
<dl><dt><strong>n_fields</strong> = 9</dl>
<dl><dt><strong>n_sequence_fields</strong> = 9</dl>
<dl><dt><strong>n_unnamed_fields</strong> = 0</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-asctime"><strong>asctime</strong></a>(...)</dt><dd><tt><a href="#-asctime">asctime</a>([tuple]) -> string<br>
<br>
Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.<br>
When the time tuple is not present, current time as returned by <a href="#-localtime">localtime</a>()<br>
is used.</tt></dd></dl>
<dl><dt><a name="-clock"><strong>clock</strong></a>(...)</dt><dd><tt><a href="#-clock">clock</a>() -> floating point number<br>
<br>
Return the CPU time or real time since the start of the process or since<br>
the first call to <a href="#-clock">clock</a>(). This has as much precision as the system<br>
records.</tt></dd></dl>
<dl><dt><a name="-ctime"><strong>ctime</strong></a>(...)</dt><dd><tt><a href="#-ctime">ctime</a>(seconds) -> string<br>
<br>
Convert a time in seconds since the Epoch to a string in local time.<br>
This is equivalent to <a href="#-asctime">asctime</a>(<a href="#-localtime">localtime</a>(seconds)). When the time tuple is<br>
not present, current time as returned by <a href="#-localtime">localtime</a>() is used.</tt></dd></dl>
<dl><dt><a name="-gmtime"><strong>gmtime</strong></a>(...)</dt><dd><tt><a href="#-gmtime">gmtime</a>([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,<br>
tm_sec, tm_wday, tm_yday, tm_isdst)<br>
<br>
Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.<br>
GMT). When 'seconds' is not passed in, convert the current time instead.</tt></dd></dl>
<dl><dt><a name="-localtime"><strong>localtime</strong></a>(...)</dt><dd><tt><a href="#-localtime">localtime</a>([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,<br>
tm_sec,tm_wday,tm_yday,tm_isdst)<br>
<br>
Convert seconds since the Epoch to a time tuple expressing local time.<br>
When 'seconds' is not passed in, convert the current time instead.</tt></dd></dl>
<dl><dt><a name="-mktime"><strong>mktime</strong></a>(...)</dt><dd><tt><a href="#-mktime">mktime</a>(tuple) -> floating point number<br>
<br>
Convert a time tuple in local time to seconds since the Epoch.</tt></dd></dl>
<dl><dt><a name="-sleep"><strong>sleep</strong></a>(...)</dt><dd><tt><a href="#-sleep">sleep</a>(seconds)<br>
<br>
Delay execution for a given number of seconds. The argument may be<br>
a floating point number for subsecond precision.</tt></dd></dl>
<dl><dt><a name="-strftime"><strong>strftime</strong></a>(...)</dt><dd><tt><a href="#-strftime">strftime</a>(format[, tuple]) -> string<br>
<br>
Convert a time tuple to a string according to a format specification.<br>
See the library reference manual for formatting codes. When the time tuple<br>
is not present, current time as returned by <a href="#-localtime">localtime</a>() is used.</tt></dd></dl>
<dl><dt><a name="-strptime"><strong>strptime</strong></a>(...)</dt><dd><tt><a href="#-strptime">strptime</a>(string, format) -> <a href="#struct_time">struct_time</a><br>
<br>
Parse a string to a time tuple according to a format specification.<br>
See the library reference manual for formatting codes (same as <a href="#-strftime">strftime</a>()).</tt></dd></dl>
<dl><dt><a name="-time"><strong>time</strong></a>(...)</dt><dd><tt><a href="#-time">time</a>() -> floating point number<br>
<br>
Return the current time in seconds since the Epoch.<br>
Fractions of a second may be present if the system clock provides them.</tt></dd></dl>
<dl><dt><a name="-tzset"><strong>tzset</strong></a>(...)</dt><dd><tt><a href="#-tzset">tzset</a>()<br>
<br>
Initialize, or reinitialize, the local timezone to the value stored in<br>
os.environ['TZ']. The TZ environment variable should be specified in<br>
standard Unix timezone format as documented in the tzset man page<br>
(eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently<br>
fall back to UTC. If the TZ environment variable is not set, the local<br>
timezone is set to the systems best guess of wallclock time.<br>
Changing the TZ environment variable without calling tzset *may* change<br>
the local timezone used by methods such as localtime, but this behaviour<br>
should not be relied on.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>accept2dyear</strong> = 1<br>
<strong>altzone</strong> = 25200<br>
<strong>daylight</strong> = 1<br>
<strong>timezone</strong> = 28800<br>
<strong>tzname</strong> = ('PST', 'PDT')</td></tr></table>
</body></html>
|