summaryrefslogtreecommitdiff
path: root/src/op_mode/powerctrl.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/op_mode/powerctrl.py')
-rwxr-xr-xsrc/op_mode/powerctrl.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/op_mode/powerctrl.py b/src/op_mode/powerctrl.py
index a70418801..d33f8633d 100755
--- a/src/op_mode/powerctrl.py
+++ b/src/op_mode/powerctrl.py
@@ -20,11 +20,16 @@ import re
from argparse import ArgumentParser
from datetime import datetime, timedelta, time as type_time, date as type_date
from sys import exit
+from time import time
from vyos.util import ask_yes_no, cmd, call, run, STDOUT
systemd_sched_file = "/run/systemd/shutdown/scheduled"
+def utc2local(datetime):
+ now = time()
+ offs = datetime.fromtimestamp(now) - datetime.utcfromtimestamp(now)
+ return datetime + offs
def parse_time(s):
try:
@@ -66,11 +71,12 @@ def get_shutdown_status():
def check_shutdown():
output = get_shutdown_status()
+ dt = datetime.strptime(output['DATETIME'], '%Y-%m-%d %H:%M:%S')
if output and 'MODE' in output:
if output['MODE'] == 'reboot':
- print("Reboot is scheduled", output['DATETIME'])
+ print("Reboot is scheduled", utc2local(dt))
elif output['MODE'] == 'poweroff':
- print("Poweroff is scheduled", output['DATETIME'])
+ print("Poweroff is scheduled", utc2local(dt))
else:
print("Reboot or poweroff is not scheduled")