Skip to content

Commit 8ddd5d7

Browse files
committed
add test for pre-epoch datetime
1 parent 4ea42eb commit 8ddd5d7

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

test/test_timestamp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ def test_timestamp_datetime():
103103

104104
assert Timestamp.from_datetime(ts).to_datetime() == ts
105105

106+
# Regression test: pre-epoch fractional seconds must floor toward -inf.
107+
pre_epoch = datetime.datetime(1969, 12, 31, 23, 59, 59, 500000, tzinfo=utc)
108+
ts_pre_epoch = Timestamp.from_datetime(pre_epoch)
109+
assert ts_pre_epoch.seconds == -1
110+
assert ts_pre_epoch.nanoseconds == 500000000
111+
assert ts_pre_epoch.to_datetime() == pre_epoch
112+
106113

107114
def test_unpack_datetime():
108115
t = Timestamp(42, 14)

0 commit comments

Comments
 (0)