Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
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
2 changes: 1 addition & 1 deletion 2 msgpack/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ def from_datetime(dt):

:rtype: Timestamp
"""
return Timestamp(seconds=int(dt.timestamp()), nanoseconds=dt.microsecond * 1000)
return Timestamp(seconds=int(dt.timestamp() // 1), nanoseconds=dt.microsecond * 1000)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

7 changes: 7 additions & 0 deletions 7 test/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ def test_timestamp_datetime():

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

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


def test_unpack_datetime():
t = Timestamp(42, 14)
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.