Skip to content
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 src/zeroconf/_utils/time.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

cpdef double current_time_millis()

cpdef millis_to_seconds(object millis)
cpdef millis_to_seconds(double millis)
6 changes: 4 additions & 2 deletions src/zeroconf/_utils/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
_float = float


def current_time_millis() -> float:
def current_time_millis() -> _float:
"""Current time in milliseconds.

The current implemention uses `time.monotonic`
but may change in the future.

The design requires the time to match asyncio.loop.time()
"""
return time.monotonic() * 1000


def millis_to_seconds(millis: _float) -> float:
def millis_to_seconds(millis: _float) -> _float:
"""Convert milliseconds to seconds."""
return millis / 1000.0