summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/plugins/internal/Plugin.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index e9964b11d..b651079c2 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -89,22 +89,15 @@ def which(program):
return exe_file
-def seconds_to_midnight(gmt=0):
- now = datetime.datetime.utcnow() + datetime.timedelta(hours=gmt)
-
- if now.hour == 0 and now.minute < 10:
- midnight = now
+def seconds_to_midnight(gmt=None):
+ if gmt is None:
+ now = datetime.datetime.today()
else:
- midnight = now + datetime.timedelta(days=1)
-
- td = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - now
+ now = datetime.datetime.utcnow() + datetime.timedelta(hours=gmt)
- if hasattr(td, 'total_seconds'):
- res = td.total_seconds()
- else: #@NOTE: work-around for python 2.5 and 2.6 missing datetime.timedelta.total_seconds
- res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
+ midnight = now.replace(hour=0, minute=10, second=0, microsecond=0) + datetime.timedelta(days=1)
- return int(res)
+ return (midnight - now).seconds
def replace_patterns(string, ruleslist):