Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6761,6 +6761,9 @@ local_timezone_from_timestamp(time_t timestamp)
struct tm local_time_tm;
PyObject *nameo = NULL;
const char *zone = NULL;
#ifndef HAVE_STRUCT_TM_TM_ZONE
char buf[100];
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
#endif

if (_PyTime_localtime(timestamp, &local_time_tm) != 0)
return NULL;
Expand All @@ -6771,8 +6774,9 @@ local_timezone_from_timestamp(time_t timestamp)
{
PyObject *local_time, *utc_time;
struct tm utc_time_tm;
char buf[100];
strftime(buf, sizeof(buf), "%Z", &local_time_tm);
if (strftime(buf, sizeof(buf), "%Z", &local_time_tm) == 0) {
buf[0] = '\0';
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
}
zone = buf;
local_time = new_datetime(local_time_tm.tm_year + 1900,
local_time_tm.tm_mon + 1,
Expand All @@ -6783,8 +6787,10 @@ local_timezone_from_timestamp(time_t timestamp)
if (local_time == NULL) {
return NULL;
}
if (_PyTime_gmtime(timestamp, &utc_time_tm) != 0)
if (_PyTime_gmtime(timestamp, &utc_time_tm) != 0) {
Py_DECREF(local_time);
return NULL;
}
utc_time = new_datetime(utc_time_tm.tm_year + 1900,
utc_time_tm.tm_mon + 1,
utc_time_tm.tm_mday,
Expand Down
Loading