1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

fix for rtc configured as UTC

This commit is contained in:
Kelly Brazil
2023-03-13 19:47:38 -07:00
parent 894946b207
commit 9b5c25cb5b

View File

@ -64,7 +64,7 @@ import jc.utils
class info(): class info():
"""Provides parser metadata (version, author, etc.)""" """Provides parser metadata (version, author, etc.)"""
version = '1.7' version = '1.8'
description = '`timedatectl status` command parser' description = '`timedatectl status` command parser'
author = 'Kelly Brazil' author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com' author_email = 'kellyjonbrazil@gmail.com'
@ -120,15 +120,25 @@ def parse(data, raw=False, quiet=False):
jc.utils.input_type_check(data) jc.utils.input_type_check(data)
raw_output = {} raw_output = {}
valid_fields = [
'local time', 'universal time', 'rtc time', 'time zone', 'ntp enabled',
'ntp synchronized', 'rtc in local tz', 'dst active', 'system clock synchronized',
'ntp service', 'systemd-timesyncd.service active'
]
if jc.utils.has_data(data): if jc.utils.has_data(data):
for line in filter(None, data.splitlines()): for line in filter(None, data.splitlines()):
linedata = line.split(':', maxsplit=1) try:
raw_output[linedata[0].strip().lower().replace(' ', '_')] = linedata[1].strip() key, val = line.split(':', maxsplit=1)
key = key.lower().strip()
val = val.strip()
except ValueError:
continue
if linedata[0].strip() == 'DST active': if key in valid_fields:
break keyname = key.replace(' ', '_')
raw_output[keyname] = val
if raw: if raw:
return raw_output return raw_output