Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 57d5752

Browse files
committed
Update to better reflect the usage of struct_time instances throughout;
continuing to call these "time tuples" is misleading at best. Closes SF bug #671731; will backport to 2.2.x.
1 parent 5bbeb8d commit 57d5752

1 file changed

Lines changed: 28 additions & 24 deletions

File tree

Doc/lib/libtime.tex

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ \section{\module{time} ---
2929
\strong{Year 2000 (Y2K) issues}:\index{Year 2000}\index{Y2K} Python
3030
depends on the platform's C library, which generally doesn't have year
3131
2000 issues, since all dates and times are represented internally as
32-
seconds since the epoch. Functions accepting a time tuple (see below)
33-
generally require a 4-digit year. For backward compatibility, 2-digit
34-
years are supported if the module variable \code{accept2dyear} is a
35-
non-zero integer; this variable is initialized to \code{1} unless the
36-
environment variable \envvar{PYTHONY2K} is set to a non-empty string,
37-
in which case it is initialized to \code{0}. Thus, you can set
32+
seconds since the epoch. Functions accepting a \class{struct_time}
33+
(see below) generally require a 4-digit year. For backward
34+
compatibility, 2-digit years are supported if the module variable
35+
\code{accept2dyear} is a non-zero integer; this variable is
36+
initialized to \code{1} unless the environment variable
37+
\envvar{PYTHONY2K} is set to a non-empty string, in which case it is
38+
initialized to \code{0}. Thus, you can set
3839
\envvar{PYTHONY2K} to a non-empty string in the environment to require 4-digit
3940
years for all year input. When 2-digit years are accepted, they are
4041
converted according to the \POSIX{} or X/Open standard: values 69-99
@@ -99,11 +100,11 @@ \section{\module{time} ---
99100
result in the correct daylight savings state to be filled in.
100101

101102
When a tuple with an incorrect length is passed to a function
102-
expecting a time tuple, or having elements of the wrong type, a
103+
expecting a \class{struct_time}, or having elements of the wrong type, a
103104
\exception{TypeError} is raised.
104105

105106
\versionchanged[The time value sequence was changed from a tuple to a
106-
specialized type, with the addition of attribute names
107+
\class{struct_time}, with the addition of attribute names
107108
for the fields]{2.2}
108109
\end{itemize}
109110

@@ -124,15 +125,16 @@ \section{\module{time} ---
124125
\code{daylight} is nonzero.
125126
\end{datadesc}
126127

127-
\begin{funcdesc}{asctime}{\optional{tuple}}
128-
Convert a tuple representing a time as returned by \function{gmtime()}
128+
\begin{funcdesc}{asctime}{\optional{t}}
129+
Convert a tuple or \class{struct_time} representing a time as returned
130+
by \function{gmtime()}
129131
or \function{localtime()} to a 24-character string of the following form:
130-
\code{'Sun Jun 20 23:21:05 1993'}. If \var{tuple} is not provided, the
132+
\code{'Sun Jun 20 23:21:05 1993'}. If \var{t} is not provided, the
131133
current time as returned by \function{localtime()} is used.
132134
Locale information is not used by \function{asctime()}.
133135
\note{Unlike the C function of the same name, there is no trailing
134136
newline.}
135-
\versionchanged[Allowed \var{tuple} to be omitted]{2.1}
137+
\versionchanged[Allowed \var{t} to be omitted]{2.1}
136138
\end{funcdesc}
137139

138140
\begin{funcdesc}{clock}{}
@@ -164,11 +166,11 @@ \section{\module{time} ---
164166
\end{datadesc}
165167

166168
\begin{funcdesc}{gmtime}{\optional{secs}}
167-
Convert a time expressed in seconds since the epoch to a time tuple
169+
Convert a time expressed in seconds since the epoch to a \class{struct_time}
168170
in UTC in which the dst flag is always zero. If \var{secs} is not
169171
provided, the current time as returned by \function{time()} is used.
170172
Fractions of a second are ignored. See above for a description of the
171-
tuple lay-out.
173+
\class{struct_time} object.
172174
\versionchanged[Allowed \var{secs} to be omitted]{2.1}
173175
\end{funcdesc}
174176

@@ -178,10 +180,11 @@ \section{\module{time} ---
178180
\versionchanged[Allowed \var{secs} to be omitted]{2.1}
179181
\end{funcdesc}
180182

181-
\begin{funcdesc}{mktime}{tuple}
183+
\begin{funcdesc}{mktime}{t}
182184
This is the inverse function of \function{localtime()}. Its argument
183-
is the full 9-tuple (since the dst flag is needed; use \code{-1} as
184-
the dst flag if it is unknown) which expresses the time in
185+
is the \class{struct_time} or full 9-tuple (since the dst flag is
186+
needed; use \code{-1} as the dst flag if it is unknown) which
187+
expresses the time in
185188
\emph{local} time, not UTC. It returns a floating point number, for
186189
compatibility with \function{time()}. If the input value cannot be
187190
represented as a valid time, either \exception{OverflowError} or
@@ -200,12 +203,13 @@ \section{\module{time} ---
200203
the scheduling of other activity in the system.
201204
\end{funcdesc}
202205

203-
\begin{funcdesc}{strftime}{format\optional{, tuple}}
204-
Convert a tuple representing a time as returned by \function{gmtime()}
205-
or \function{localtime()} to a string as specified by the \var{format}
206-
argument. If \var{tuple} is not provided, the current time as returned by
207-
\function{localtime()} is used. \var{format} must be a string.
208-
\versionchanged[Allowed \var{tuple} to be omitted]{2.1}
206+
\begin{funcdesc}{strftime}{format\optional{, t}}
207+
Convert a tuple or \class{struct_time} representing a time as returned
208+
by \function{gmtime()} or \function{localtime()} to a string as
209+
specified by the \var{format} argument. If \var{t} is not
210+
provided, the current time as returned by \function{localtime()} is
211+
used. \var{format} must be a string.
212+
\versionchanged[Allowed \var{t} to be omitted]{2.1}
209213

210214
The following directives can be embedded in the \var{format} string.
211215
They are shown without the optional field width and precision
@@ -277,7 +281,7 @@ \section{\module{time} ---
277281

278282
\begin{funcdesc}{strptime}{string\optional{, format}}
279283
Parse a string representing a time according to a format. The return
280-
value is a tuple as returned by \function{gmtime()} or
284+
value is a \class{struct_time} as returned by \function{gmtime()} or
281285
\function{localtime()}. The \var{format} parameter uses the same
282286
directives as those used by \function{strftime()}; it defaults to
283287
\code{"\%a \%b \%d \%H:\%M:\%S \%Y"} which matches the formatting

0 commit comments

Comments
 (0)