Skip to content

Commit 69f3a5a

Browse files
authored
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 0d659e5)
1 parent 0d17278 commit 69f3a5a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/timemodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static PyTypeObject StructTimeType;
279279
static PyObject *
280280
tmtotuple(struct tm *p
281281
#ifndef HAVE_STRUCT_TM_TM_ZONE
282-
, const char *zone, int gmtoff
282+
, const char *zone, time_t gmtoff
283283
#endif
284284
)
285285
{
@@ -305,7 +305,7 @@ tmtotuple(struct tm *p
305305
#else
306306
PyStructSequence_SET_ITEM(v, 9,
307307
PyUnicode_DecodeLocale(zone, "surrogateescape"));
308-
SET(10, gmtoff);
308+
PyStructSequence_SET_ITEM(v, 10, _PyLong_FromTime_t(gmtoff));
309309
#endif /* HAVE_STRUCT_TM_TM_ZONE */
310310
#undef SET
311311
if (PyErr_Occurred()) {
@@ -397,7 +397,7 @@ time_localtime(PyObject *self, PyObject *args)
397397
{
398398
struct tm local = buf;
399399
char zone[100];
400-
int gmtoff;
400+
time_t gmtoff;
401401
strftime(zone, sizeof(zone), "%Z", &buf);
402402
gmtoff = timegm(&buf) - when;
403403
return tmtotuple(&local, zone, gmtoff);

0 commit comments

Comments
 (0)