mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-20 04:13:16 +00:00
Fix datetime before epoch on windows in cython implementation (#436)
Cython implementation still used datetime.from_timestamp method, which does not work on windows. Update the cython implementation to use utc time and delta and add a regression test to highlight the issue.
This commit is contained in:
parent
772c830841
commit
8fb709f2e0
3 changed files with 30 additions and 13 deletions
|
@ -99,6 +99,14 @@ def test_unpack_datetime():
|
|||
assert unpacked == datetime.datetime(1970, 1, 1, 0, 0, 42, 0, tzinfo=_utc)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info[0] == 2, reason="datetime support is PY3+ only")
|
||||
def test_pack_unpack_before_epoch():
|
||||
t_in = datetime.datetime(1960, 1, 1, tzinfo=_utc)
|
||||
packed = msgpack.packb(t_in, datetime=True)
|
||||
unpacked = msgpack.unpackb(packed, timestamp=3)
|
||||
assert unpacked == t_in
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info[0] == 2, reason="datetime support is PY3+ only")
|
||||
def test_pack_datetime():
|
||||
t = Timestamp(42, 14000)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue