Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0ad55fb2
Commit
0ad55fb2
authored
Dec 08, 1998
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the descriptions of strftime() and strptime() to avoid
confusion, and describe what the "directives" are about.
parent
e94e3fbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
45 deletions
+47
-45
Doc/lib/libtime.tex
Doc/lib/libtime.tex
+47
-45
No files found.
Doc/lib/libtime.tex
View file @
0ad55fb2
...
@@ -20,35 +20,35 @@ look at \code{gmtime(0)}.%
...
@@ -20,35 +20,35 @@ look at \code{gmtime(0)}.%
\index
{
epoch
}
\index
{
epoch
}
\item
\item
The functions in this module do
n'
t handle dates and times before the
The functions in this module do
no
t handle dates and times before the
epoch or far in the future. The cut-off point in the future is
epoch or far in the future. The cut-off point in the future is
determined by the
C
library; for
\UNIX
{}
, it is typically in 2038.
%
determined by the
\C
{}
library; for
\UNIX
{}
, it is typically in 2038.
%
\index
{
Year 2038
}
\index
{
Year 2038
}
\item
\item
\strong
{
Year 2000 (Y2K) issues
}
: Python depends on the platform's
C library,
\strong
{
Year 2000 (Y2K) issues
}
: Python depends on the platform's
\C
{}
which generally doesn't have year 2000 issues, since all dates and
library, which generally doesn't have year 2000 issues, since all
times are represented internally as seconds since the epoch.
dates and times are represented internally as seconds since the
Functions accepting a time tuple (see below) generally require a
epoch. Functions accepting a time tuple (see below) generally require
4-digit year. For backward compatibility, 2-digit years are supported
a 4-digit year. For backward compatibility, 2-digit years are
if the module variable
\code
{
accept2dyear
}
is a non-zero integer; this
supported if the module variable
\code
{
accept2dyear
}
is a non-zero
variable is initialized to
\code
{
1
}
unless the environment variabl
e
integer; this variable is initialized to
\code
{
1
}
unless th
e
\code
{
PYTHONY2K
}
is set to a non-empty string, in which case it is
environment variable
\envvar
{
PYTHONY2K
}
is set to a non-empty string,
in
itialized to
\code
{
0
}
. Thus, you can set
\code
{
PYTHONY2K
}
in the
in
which case it is initialized to
\code
{
0
}
. Thus, you can set
environment to
\code
{
x
}
to require 4-digit years for all year input.
\envvar
{
PYTHONY2K
}
in the environment to
\code
{
x
}
to require 4-digit
When 2-digit years are accepted, they are converted according to th
e
years for all year input. When 2-digit years are accepted, they ar
e
POSIX or X/Open standard: values 69-99 are mapped to 1969-1999, and
converted according to the
\POSIX
{}
or X/Open standard: values 69-99
values 0--68 are mapped to 2000--2068. Values 100--1899 are always
are mapped to 1969-1999, and values 0--68 are mapped to 2000--2068.
illegal. Note that this is new as of Python 1.5.2(a2); earlier
Values 100--1899 are always illegal. Note that this is new as of
versions, up to Python 1.5.1 and 1.5.2a1, would add 1900 to year
Python 1.5.2(a2); earlier versions, up to Python 1.5.1 and 1.5.2a1,
values below 1900.
%
would add 1900 to year
values below 1900.
%
\index
{
Year 2000
}
%
\index
{
Year 2000
}
%
\index
{
Y2K
}
\index
{
Y2K
}
\item
\item
UTC is Coordinated Universal Time (formerly known as Greenwich Mean
UTC is Coordinated Universal Time (formerly known as Greenwich Mean
Time
). The acronym UTC is not a mistake but a compromise between
Time
, or GMT). The acronym UTC is not a mistake but a compromise
English and French.
%
between
English and French.
%
\index
{
UTC
}
%
\index
{
UTC
}
%
\index
{
Coordinated Universal Time
}
%
\index
{
Coordinated Universal Time
}
%
\index
{
Greenwich Mean Time
}
\index
{
Greenwich Mean Time
}
...
@@ -103,9 +103,9 @@ Only use this if \code{daylight} is nonzero.
...
@@ -103,9 +103,9 @@ Only use this if \code{daylight} is nonzero.
\end{datadesc}
\end{datadesc}
\begin{funcdesc}
{
asctime
}{
tuple
}
\begin{funcdesc}
{
asctime
}{
tuple
}
Convert a tuple representing a time as returned by
\
code
{
gmtime()
}
or
Convert a tuple representing a time as returned by
\
function
{
gmtime()
}
\code
{
localtime()
}
to a 24-character string of the following form:
or
\function
{
localtime()
}
to a 24-character string of the following form:
\code
{
'Sun Jun 20 23:21:05 1993'
}
. Note: unlike the
C
function of
\code
{
'Sun Jun 20 23:21:05 1993'
}
. Note: unlike the
\C
{}
function of
the same name, there is no trailing newline.
the same name, there is no trailing newline.
\end{funcdesc}
\end{funcdesc}
...
@@ -139,13 +139,12 @@ set to \code{1} when DST applies to the given time.
...
@@ -139,13 +139,12 @@ set to \code{1} when DST applies to the given time.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
mktime
}{
tuple
}
\begin{funcdesc}
{
mktime
}{
tuple
}
This is the inverse function of
\code
{
localtime
}
. Its argument is the
This is the inverse function of
\function
{
localtime()
}
. Its argument
full 9-tuple (since the dst flag is needed --- pass
\code
{
-1
}
as the
is the full 9-tuple (since the dst flag is needed --- pass
\code
{
-1
}
dst flag if it is unknown) which expresses the time
as the dst flag if it is unknown) which expresses the time in
in
\emph
{
local
}
time, not UTC. It returns a floating
\emph
{
local
}
time, not UTC. It returns a floating point number, for
point number, for compatibility with
\function
{
time()
}
. If the input
compatibility with
\function
{
time()
}
. If the input value cannot be
value cannot be represented as a valid time,
\exception
{
OverflowError
}
represented as a valid time,
\exception
{
OverflowError
}
is raised.
is raised.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
sleep
}{
secs
}
\begin{funcdesc}
{
sleep
}{
secs
}
...
@@ -154,11 +153,14 @@ be a floating point number to indicate a more precise sleep time.
...
@@ -154,11 +153,14 @@ be a floating point number to indicate a more precise sleep time.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
strftime
}{
format, tuple
}
\begin{funcdesc}
{
strftime
}{
format, tuple
}
Convert a tuple representing a time as returned by
\code
{
gmtime()
}
or
Convert a tuple representing a time as returned by
\function
{
gmtime()
}
\code
{
localtime()
}
to a string as specified by the format argument.
or
\function
{
localtime()
}
to a string as specified by the
\var
{
format
}
argument.
\var
{
format
}
must be a string.
The following directives, shown without the optional field width and
The following directives can be embedded in the
\var
{
format
}
string.
precision specification, are replaced by the indicated characters:
They are shown without the optional field width and precision
specification, and are replaced by the indicated characters in the
\function
{
strftime()
}
result:
\begin{tableii}
{
c|p
{
24em
}}{
code
}{
Directive
}{
Meaning
}
\begin{tableii}
{
c|p
{
24em
}}{
code
}{
Directive
}{
Meaning
}
\lineii
{
\%
a
}{
Locale's abbreviated weekday name.
}
\lineii
{
\%
a
}{
Locale's abbreviated weekday name.
}
...
@@ -190,25 +192,25 @@ precision specification, are replaced by the indicated characters:
...
@@ -190,25 +192,25 @@ precision specification, are replaced by the indicated characters:
\end{tableii}
\end{tableii}
Additional directives may be supported on certain platforms, but
Additional directives may be supported on certain platforms, but
only the ones listed here have a meaning standardized by ANSI
C
.
only the ones listed here have a meaning standardized by ANSI
\C
{}
.
On some platforms, an optional field width and precision
On some platforms, an optional field width and precision
specification can immediately follow the initial
\c
ode
{
\%
}
of a
specification can immediately follow the initial
\c
haracter
{
\%
}
of a
directive in the following order; this is also not portable.
directive in the following order; this is also not portable.
The field width is normally 2 except for
\code
{
\%
j
}
where it is 3.
The field width is normally 2 except for
\code
{
\%
j
}
where it is 3.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
strptime
}{
string
\optional
{
, format
}}
\begin{funcdesc}
{
strptime
}{
string
\optional
{
, format
}}
Parse a string representing a time according to a format. The return
Parse a string representing a time according to a format. The return
value is a tuple as returned by
\code
{
gmtime()
}
or
\code
{
localtime()
}
.
value is a tuple as returned by
\function
{
gmtime()
}
or
The format uses the same directives as those used by
\function
{
localtime()
}
. The
\var
{
format
}
parameter uses the same
\code
{
strftime()
}
; it defaults to
\code
{
"
\%
a
\%
b
\%
d
\%
H:
\%
M:
\%
S
\%
Y"
}
directives as those used by
\function
{
strftime()
}
; it defaults to
which matches the formatting returned by
\code
{
ctime()
}
. The same
\code
{
"
\%
a
\%
b
\%
d
\%
H:
\%
M:
\%
S
\%
Y"
}
which matches the formatting
platform caveats apply; see the local Unix documentation for
returned by
\function
{
ctime()
}
. The same platform caveats apply; see
restrictions or additional supported directives. This function may
the local
\UNIX
{}
documentation for restrictions or additional
not be defined on all platforms.
supported directives. If
\var
{
string
}
cannot be parsed according to
\var
{
format
}
,
\exception
{
ValueError
}
is raised. This function may not
be defined on all platforms.
\end{funcdesc}
\end{funcdesc}
\begin{funcdesc}
{
time
}{}
\begin{funcdesc}
{
time
}{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment