summaryrefslogtreecommitdiffstats
path: root/Modules/datetimemodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-01-04 18:17:36 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-01-04 18:17:36 (GMT)
commit75a6e3bd1a91ae1d7e4bb30f73052d1b89bca524 (patch)
treec9ceb8bf3fb8635c783d2ebfed37f7dd6e299f8f /Modules/datetimemodule.c
parent85e4c6757f3b323870b24dad4b39b1572b8a292c (diff)
downloadcpython-75a6e3bd1a91ae1d7e4bb30f73052d1b89bca524.zip
cpython-75a6e3bd1a91ae1d7e4bb30f73052d1b89bca524.tar.gz
cpython-75a6e3bd1a91ae1d7e4bb30f73052d1b89bca524.tar.bz2
datetime_from_timet_and_us(): ignore leap seconds if the platform
localtime()/gmtime() insists on delivering them, + associated doc changes. Redid the docs for datetimtez.astimezone().
Diffstat (limited to 'Modules/datetimemodule.c')
-rw-r--r--Modules/datetimemodule.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 6e28336..54e6aac 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -2831,7 +2831,15 @@ datetime_from_timet_and_us(PyObject *cls, TM_FUNC f, time_t timet, int us)
PyObject *result = NULL;
tm = f(&timet);
- if (tm)
+ if (tm) {
+ /* The platform localtime/gmtime may insert leap seconds,
+ * indicated by tm->tm_sec > 59. We don't care about them,
+ * except to the extent that passing them on to the datetime
+ * constructor would raise ValueError for a reason that
+ * made no sense to the user.
+ */
+ if (tm->tm_sec > 59)
+ tm->tm_sec = 59;
result = PyObject_CallFunction(cls, "iiiiiii",
tm->tm_year + 1900,
tm->tm_mon + 1,
@@ -2840,6 +2848,7 @@ datetime_from_timet_and_us(PyObject *cls, TM_FUNC f, time_t timet, int us)
tm->tm_min,
tm->tm_sec,
us);
+ }
else
PyErr_SetString(PyExc_ValueError,
"timestamp out of range for "