merge diffusions and episode, work on different fixes, duration are timefield, make it work

This commit is contained in:
bkfox
2015-11-22 23:24:19 +01:00
parent 44fc4dae31
commit 25e3d4cb53
10 changed files with 357 additions and 189 deletions

View File

@ -1,6 +1,23 @@
import datetime
def to_timedelta (time):
"""
Transform a datetime or a time instance to a timedelta,
only using time info
"""
return datetime.timedelta(
hours = time.hour,
minutes = time.minute,
seconds = time.seconds
)
def seconds_to_time (seconds):
"""
Seconds to datetime.time
"""
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
return datetime.time(hour = hours, minute = minutes, second = seconds)
def ensure_list (value):
if type(value) in (list, set, tuple):
return value
return [value]