Skip to content
Draft
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
10 changes: 6 additions & 4 deletions ably/types/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
from ably.util.crypto import CipherData
from ably.util.encoding import encode_data

# The Unix epoch as a naive datetime. Presence timestamps are naive and interpreted as
# UTC, both the ones decoded off the wire and the ones callers pass in.
_EPOCH = datetime(1970, 1, 1)


def _ms_since_epoch(dt):
epoch = datetime.utcfromtimestamp(0)
delta = dt - epoch
delta = dt - _EPOCH
return int(delta.total_seconds() * 1000)


def _dt_from_ms_epoch(ms):
epoch = datetime.utcfromtimestamp(0)
return epoch + timedelta(milliseconds=ms)
return _EPOCH + timedelta(milliseconds=ms)


class PresenceAction:
Expand Down
Loading