diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-05-17 21:45:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-17 21:45:45 (GMT) |
commit | 69f3a5ac28041fac86897e0c90d98ad9fd6fa3f7 (patch) | |
tree | 178153618dde23a83d411a3e9268bfe74f2ceceb | |
parent | 0d1727835f44492c7357b013d94539e3891adf77 (diff) | |
download | cpython-69f3a5ac28041fac86897e0c90d98ad9fd6fa3f7.zip cpython-69f3a5ac28041fac86897e0c90d98ad9fd6fa3f7.tar.gz cpython-69f3a5ac28041fac86897e0c90d98ad9fd6fa3f7.tar.bz2 |
tmtotuple(): use time_t for gmtoff (#1276) (#1635)
timegm() return type is time_t, not int. Use time_t to prevent the
following compiler warning on Windows:
timemodule.c: warning C4244: '=': conversion from 'time_t' to 'int',
possible loss of data
(cherry picked from commit 0d659e5614cad512a1940125135b443b3eecb5d7)
-rw-r--r-- | Modules/timemodule.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index ebd44ad..328b84f 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -279,7 +279,7 @@ static PyTypeObject StructTimeType; static PyObject * tmtotuple(struct tm *p #ifndef HAVE_STRUCT_TM_TM_ZONE - , const char *zone, int gmtoff + , const char *zone, time_t gmtoff #endif ) { @@ -305,7 +305,7 @@ tmtotuple(struct tm *p #else PyStructSequence_SET_ITEM(v, 9, PyUnicode_DecodeLocale(zone, "surrogateescape")); - SET(10, gmtoff); + PyStructSequence_SET_ITEM(v, 10, _PyLong_FromTime_t(gmtoff)); #endif /* HAVE_STRUCT_TM_TM_ZONE */ #undef SET if (PyErr_Occurred()) { @@ -397,7 +397,7 @@ time_localtime(PyObject *self, PyObject *args) { struct tm local = buf; char zone[100]; - int gmtoff; + time_t gmtoff; strftime(zone, sizeof(zone), "%Z", &buf); gmtoff = timegm(&buf) - when; return tmtotuple(&local, zone, gmtoff); |