sintonia/playout/pypo/pure.py

26 lines
598 B
Python
Raw Normal View History

import re
2020-01-23 11:37:49 +01:00
from packaging.version import Version, parse
2021-05-27 16:23:02 +02:00
def version_cmp(version1, version2):
2020-01-23 11:37:49 +01:00
version1 = parse(version1)
version2 = parse(version2)
if version1 > version2:
return 1
if version1 == version2:
return 0
return -1
2021-05-27 16:23:02 +02:00
def date_interval_to_seconds(interval):
"""
Convert timedelta object into int representing the number of seconds. If
number of seconds is less than 0, then return 0.
"""
2021-05-27 16:23:02 +02:00
seconds = (
interval.microseconds + (interval.seconds + interval.days * 24 * 3600) * 10 ** 6
) / float(10 ** 6)
return seconds