Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion msgpack/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ def to_datetime(self):
:rtype: `datetime.datetime`
"""
utc = datetime.timezone.utc
return datetime.datetime.fromtimestamp(0, utc) + datetime.timedelta(
utcDatetime = datetime.datetime.fromtimestamp(0, utc) + datetime.timedelta(
seconds=self.seconds, microseconds=self.nanoseconds // 1000
)
return utcDatetime.astimezone(tz=None)

@staticmethod
def from_datetime(dt):
Expand Down
4 changes: 3 additions & 1 deletion msgpack/unpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,12 @@ static int unpack_callback_ext(unpack_user* u, const char* base, const char* pos
return -1;
}

py = PyNumber_Add(epoch, d);
PyObject *added = PyNumber_Add(epoch, d);
py = PyObject_CallMethod(added, "astimezone", "O", Py_None);

Py_DECREF(epoch);
Py_DECREF(d);
Py_DECREF(added);
}
else { // float
PyObject *a = PyFloat_FromDouble((double)ts.tv_nsec);
Expand Down
Loading