MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / datetime_to_timestamp

Function datetime_to_timestamp

dwave/cloud/utils/time.py:28–36  ·  view source on GitHub ↗

Convert timezone-aware `datetime` to POSIX timestamp and return seconds since UNIX epoch. Note: similar to `datetime.timestamp()` in Python 3.3+.

(dt: datetime)

Source from the content-addressed store, hash-verified

26
27
28def datetime_to_timestamp(dt: datetime) -> float:
29 """Convert timezone-aware `datetime` to POSIX timestamp and
30 return seconds since UNIX epoch.
31
32 Note: similar to `datetime.timestamp()` in Python 3.3+.
33 """
34
35 epoch = datetime.fromtimestamp(0, tz=UTC)
36 return (dt - epoch).total_seconds()
37
38
39def utcnow() -> datetime:

Callers 4

wrappedFunction · 0.90
_set_clock_diffMethod · 0.90
_poll_using_backoffMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected