Skip to content

Commit

Permalink
tmtotuple(): use time_t for gmtoff (#1276) (#1635)
Browse files Browse the repository at this point in the history
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 0d659e5)
  • Loading branch information
vstinner committed May 17, 2017
1 parent 0d17278 commit 69f3a5a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Modules/timemodule.c
Expand Up @@ -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
)
{
Expand All @@ -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()) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 69f3a5a

Please sign in to comment.