diff options
author | Georg Brandl <georg@python.org> | 2007-07-12 09:06:41 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-07-12 09:06:41 (GMT) |
commit | c8011d649e95e0eb997bb1e5e805696add89eba2 (patch) | |
tree | 9455ba3ef95945c5e4007bfd1236789c02ff624b /Doc/lib | |
parent | 7c3b50db6614c677588096191d432e734257a244 (diff) | |
download | cpython-c8011d649e95e0eb997bb1e5e805696add89eba2.zip cpython-c8011d649e95e0eb997bb1e5e805696add89eba2.tar.gz cpython-c8011d649e95e0eb997bb1e5e805696add89eba2.tar.bz2 |
Patch #1731659: improve time.strptime docs.
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libtime.tex | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/Doc/lib/libtime.tex b/Doc/lib/libtime.tex index e276045..8a45bfcc 100644 --- a/Doc/lib/libtime.tex +++ b/Doc/lib/libtime.tex @@ -309,15 +309,23 @@ The field width is normally 2 except for \code{\%j} where it is 3. \begin{funcdesc}{strptime}{string\optional{, format}} Parse a string representing a time according to a format. The return value is a \class{struct_time} as returned by \function{gmtime()} or -\function{localtime()}. The \var{format} parameter uses the same -directives as those used by \function{strftime()}; it defaults to -\code{"\%a \%b \%d \%H:\%M:\%S \%Y"} which matches the formatting -returned by \function{ctime()}. If \var{string} cannot be parsed -according to \var{format}, \exception{ValueError} is raised. If the -string to be parsed has excess data after parsing, -\exception{ValueError} is raised. The default values used to fill in -any missing data when more accurate values cannot be inferred are -\code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)} . +\function{localtime()}. + +The \var{format} parameter uses the same directives as those used by +\function{strftime()}; it defaults to \code{"\%a \%b \%d \%H:\%M:\%S + \%Y"} which matches the formatting returned by \function{ctime()}. +If \var{string} cannot be parsed according to \var{format}, or if it +has excess data after parsing, \exception{ValueError} is raised. The +default values used to fill in any missing data when more accurate +values cannot be inferred are \code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)}. + +For example: + +\begin{verbatim} +>>> import time +>>> time.strptime("30 Nov 00", "%d %b %y") +(2000, 11, 30, 0, 0, 0, 3, 335, -1) +\end{verbatim} Support for the \code{\%Z} directive is based on the values contained in \code{tzname} and whether \code{daylight} is true. Because of this, |