summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-26 13:41:32 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-26 13:41:33 +0200
commitd6384b2014c5877cb1cc7e24b1ab2c8562c5f126 (patch)
treea501589c21a7d2dadf5fc82c4f0686699e31f613
parent748201ba9517c4ca7098025afaed98d947df2bbe (diff)
downloadvyos-1x-d6384b2014c5877cb1cc7e24b1ab2c8562c5f126.tar.gz
vyos-1x-d6384b2014c5877cb1cc7e24b1ab2c8562c5f126.zip
powerctl: T2010: report reboot time in current timezone
Do not inform the user when the reboot will happen in UTC, use the local timezone instead.
-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")