|
@@ -951,22 +951,6 @@ class LogicError(Exception):
|
|
pass
|
|
pass
|
|
|
|
|
|
|
|
|
|
-def round_time(dt=None, precision=60):
|
|
|
|
- """Round a datetime object to any time lapse in seconds
|
|
|
|
- dt : datetime.datetime object, default now.
|
|
|
|
- roundTo : Closest number of seconds to round to, default 1 minute.
|
|
|
|
- Author: Thierry Husson 2012 - Use it as you want but don't blame me.
|
|
|
|
- """
|
|
|
|
- if dt is None:
|
|
|
|
- dt = datetime.datetime.now()
|
|
|
|
- if isinstance(precision, datetime.timedelta):
|
|
|
|
- precision = precision.total_seconds()
|
|
|
|
- seconds = (dt.replace(tzinfo=None) - dt.min).seconds
|
|
|
|
- rounding = (seconds + precision / 2) // precision * precision
|
|
|
|
- return dt + datetime.timedelta(seconds=rounding - seconds,
|
|
|
|
- microseconds=dt.microsecond)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def chunks(lst, n):
|
|
def chunks(lst, n):
|
|
"""Yield successive n-sized chunks from lst."""
|
|
"""Yield successive n-sized chunks from lst."""
|
|
for i in range(0, len(lst), n):
|
|
for i in range(0, len(lst), n):
|