Utils unifi_video.utils
¶
-
unifi_video.utils.
dt_resolvable_to_ms
(resolvable, utc_offset=0, resolution=60000.0)[source]¶ Convert datetime resolvable to milliseconds since the Unix epoch.
Parameters: - resolvable (datetime or int or str) – Object that is resolvable to a date and time (see below)
- utc_offset (int) – UTC offset in seconds
- resolution (int) – Max resolution (in ms) for the returned timestamp. Default is to mimic UniFi Video frontend in providing at most minute granularity.
Returns: Milliseconds since the Unix epoch
Return type: int
- On datetime resolvables
The type of the
resolvable
parameter will affect the return value.datetime: Naive datetime values are offset by
utc_offset
while TZ aware datetime values are offset by whatevertimedelta
theirdatetime.datetime.utcoffset()
returns.str: Strings are treated as naive datetime values and should follow ISO8601 in including at least the
YYYY
,MM
, andDD
parts in eitherYYYY-MM-DD
orYYYYMMDD
.int: Ints are assumed to be UNIX timestamps; only ms conversion and granularity changes will be applied.