Skip to content

Commit 0d659e5

Browse files
authored
tmtotuple(): use time_t for gmtoff (python#1276)
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
1 parent 4bcfa3a commit 0d659e5

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
@@ -278,7 +278,7 @@ static PyTypeObject StructTimeType;
278278
static PyObject *
279279
tmtotuple(struct tm *p
280280
#ifndef HAVE_STRUCT_TM_TM_ZONE
281-
, const char *zone, int gmtoff
281+
, const char *zone, time_t gmtoff
282282
#endif
283283
)
284284
{
@@ -304,7 +304,7 @@ tmtotuple(struct tm *p
304304
#else
305305
PyStructSequence_SET_ITEM(v, 9,
306306
PyUnicode_DecodeLocale(zone, "surrogateescape"));
307-
SET(10, gmtoff);
307+
PyStructSequence_SET_ITEM(v, 10, _PyLong_FromTime_t(gmtoff));
308308
#endif /* HAVE_STRUCT_TM_TM_ZONE */
309309
#undef SET
310310
if (PyErr_Occurred()) {
@@ -396,7 +396,7 @@ time_localtime(PyObject *self, PyObject *args)
396396
{
397397
struct tm local = buf;
398398
char zone[100];
399-
int gmtoff;
399+
time_t gmtoff;
400400
strftime(zone, sizeof(zone), "%Z", &buf);
401401
gmtoff = timegm(&buf) - when;
402402
return tmtotuple(&local, zone, gmtoff);

0 commit comments

Comments
 (0)