Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit b8e5c1c

Browse files
committed
Function for making a timestamp into a datetime value
1 parent 2c6440f commit b8e5c1c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lifx/protocol.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from binascii import hexlify
33
from collections import namedtuple
44
from pkg_resources import iter_entry_points
5+
from datetime import datetime
56

67
UINT16_MAX = pow(2, 16) - 1
78
LABEL_MAXLEN = 32
@@ -398,6 +399,12 @@ def mac_string(device_id):
398399
"""
399400
return hexlify(byteswap('6', pack('u48', device_id)))
400401

402+
def timestamp_datetime(timestamp):
403+
"""
404+
Converts a timestamp from the device to a python datetime value
405+
"""
406+
return datetime.fromtimestamp(timestamp / 1000000000.0)
407+
401408
def version_string(version):
402409
"""
403410
Converts a version number into a version string

0 commit comments

Comments
 (0)