]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make temporary change of using _strptime for time.strptime permanent.
authorBrett Cannon <bcannon@gmail.com>
Tue, 1 Jul 2003 05:16:08 +0000 (05:16 +0000)
committerBrett Cannon <bcannon@gmail.com>
Tue, 1 Jul 2003 05:16:08 +0000 (05:16 +0000)
Flesh out docs to better explain time.strptime (closes bug #697990).

Doc/lib/libtime.tex
Misc/NEWS
Modules/timemodule.c

index 5f838cf76706c4fa0b7c8d270c5873010fcdf421..6fe11ecd8f960a04833e37dd9d3e5df6f3d40199 100644 (file)
@@ -288,14 +288,17 @@ 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()}.  The same platform caveats apply; see
-the local \UNIX{} documentation for restrictions or additional
-supported directives.  If \var{string} cannot be parsed according to
-\var{format}, \exception{ValueError} is raised.  Values which are not
-provided as part of the input string are filled in with default
-values; the specific values are platform-dependent as the XPG standard
-does not provide sufficient information to constrain the result.
-\end{funcdesc}
+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 is \code{(1900, 1, 1, 0, 0, 0, 0, 1, -1)} .
+
+Support for the \code{\%Z} directive is based on the values contained in
+\code{tzname} and whether \code{daylight} is true.  Because of this
+it is platform-specifc sans recognition for UTC and GMT which are
+always known (and are considered to be non-daylight savings
+timezones).
 
 \begin{datadesc}{struct_time}
 The type of the time value sequence returned by \function{gmtime()},
index af190bd4faaebcef8b3b58c16a3b8381f0ac70eb..76ec6739b72f7ae0788caed907f5e328c3e4b72c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,9 @@ Extension modules
 
 - SSL no longer crashes the interpreter when the remote side disconnects.
 
+- time.strptime now exclusively uses the Python implementation
+  contained within the _strptime module.
+
 Library
 -------
 
index ce252811ec0b371b83cc9dc18bc914bcbcfdc543..0f7b1434f1f41e257f2a9ddf2133fdc912338da4 100644 (file)
@@ -416,44 +416,6 @@ See the library reference manual for formatting codes. When the time tuple\n\
 is not present, current time as returned by localtime() is used.");
 #endif /* HAVE_STRFTIME */
 
-#undef HAVE_STRPTIME
-#ifdef HAVE_STRPTIME
-
-#if 0
-/* Enable this if it's not declared in <time.h> */
-extern char *strptime(const char *, const char *, struct tm *);
-#endif
-
-static PyObject *
-time_strptime(PyObject *self, PyObject *args)
-{
-       struct tm tm;
-       char *fmt = "%a %b %d %H:%M:%S %Y";
-       char *buf;
-       char *s;
-
-       if (!PyArg_ParseTuple(args, "s|s:strptime", &buf, &fmt))
-               return NULL;
-       memset((void *) &tm, '\0', sizeof(tm));
-       s = strptime(buf, fmt, &tm);
-       if (s == NULL) {
-               PyErr_SetString(PyExc_ValueError, "format mismatch");
-               return NULL;
-       }
-       while (*s && isspace(Py_CHARMASK(*s)))
-               s++;
-       if (*s) {
-               PyErr_Format(PyExc_ValueError,
-                            "unconverted data remains: '%.400s'", s);
-               return NULL;
-       }
-       return tmtotuple(&tm);
-}
-
-#endif /* HAVE_STRPTIME */
-
-#ifndef HAVE_STRPTIME
-
 static PyObject *
 time_strptime(PyObject *self, PyObject *args)
 {
@@ -467,10 +429,8 @@ time_strptime(PyObject *self, PyObject *args)
     return strptime_result;
 }
 
-#endif /* !HAVE_STRPTIME */
-
 PyDoc_STRVAR(strptime_doc,
-"strptime(string, format) -> tuple\n\
+"strptime(string, format) -> struct_time\n\
 \n\
 Parse a string to a time tuple according to a format specification.\n\
 See the library reference manual for formatting codes (same as strftime()).");