1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-15 01:24:29 +02:00
Files
.github
docs
parsers
acpi.md
airport.md
airport_s.md
arp.md
asciitable.md
asciitable_m.md
blkid.md
cksum.md
crontab.md
crontab_u.md
csv.md
csv_s.md
date.md
df.md
dig.md
dir.md
dmidecode.md
dpkg_l.md
du.md
env.md
file.md
finger.md
free.md
fstab.md
group.md
gshadow.md
hash.md
hashsum.md
hciconfig.md
history.md
hosts.md
id.md
ifconfig.md
ini.md
iostat.md
iostat_s.md
iptables.md
iw_scan.md
jar_manifest.md
jobs.md
kv.md
last.md
ls.md
ls_s.md
lsblk.md
lsmod.md
lsof.md
lsusb.md
mount.md
mpstat.md
mpstat_s.md
netstat.md
nmcli.md
ntpq.md
passwd.md
pidstat.md
pidstat_s.md
ping.md
ping_s.md
pip_list.md
pip_show.md
ps.md
route.md
rpm_qi.md
rsync.md
rsync_s.md
sfdisk.md
shadow.md
ss.md
stat.md
stat_s.md
sysctl.md
systemctl.md
systemctl_lj.md
systemctl_ls.md
systemctl_luf.md
systeminfo.md
time.md
timedatectl.md
tracepath.md
traceroute.md
ufw.md
ufw_appinfo.md
uname.md
universal.md
upower.md
uptime.md
vmstat.md
vmstat_s.md
w.md
wc.md
who.md
xml.md
xrandr.md
yaml.md
zipinfo.md
lib.md
readme.md
streaming.md
utils.md
jc
man
templates
tests
.gitignore
CHANGELOG
CONTRIBUTING.md
EXAMPLES.md
LICENSE.md
MANIFEST.in
README.md
_config.yml
build-package.sh
docgen.sh
install.sh
mangen.py
pypi-upload.sh
readmegen.py
requirements.txt
runtests.sh
setup.cfg
setup.py
updatedocs.sh
jc/docs/parsers/timedatectl.md

91 lines
2.3 KiB
Markdown
Raw Normal View History

[Home](https://kellyjonbrazil.github.io/jc/)
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.timedatectl"></a>
2020-07-30 16:20:24 -07:00
2020-03-10 18:37:55 -07:00
# jc.parsers.timedatectl
2022-01-25 17:07:47 -08:00
2022-03-04 13:27:39 -08:00
jc - JSON Convert `timedatectl` command output parser
2020-03-10 18:37:55 -07:00
2022-01-19 17:30:14 -08:00
The `epoch_utc` calculated timestamp field is timezone-aware and is only
available if the `universal_time` field is available.
2020-08-05 13:32:59 -07:00
Usage (cli):
2020-03-10 18:37:55 -07:00
2022-01-25 18:03:34 -08:00
$ timedatectl | jc --timedatectl
2020-08-05 16:51:58 -07:00
2022-01-25 18:03:34 -08:00
or
2020-08-05 16:51:58 -07:00
2022-01-25 18:03:34 -08:00
$ jc timedatectl
2020-03-10 18:37:55 -07:00
2020-08-05 13:32:59 -07:00
Usage (module):
2022-01-25 18:03:34 -08:00
import jc
result = jc.parse('timedatectl', timedatectl_command_output)
2022-01-18 15:38:03 -08:00
2021-04-08 15:52:49 -07:00
Schema:
2022-01-25 18:03:34 -08:00
{
"local_time": string,
"universal_time": string,
"epoch_utc": integer, # timezone-aware
"rtc_time": string,
"time_zone": string,
"ntp_enabled": boolean,
"ntp_synchronized": boolean,
"system_clock_synchronized": boolean,
"systemd-timesyncd.service_active": boolean,
"rtc_in_local_tz": boolean,
"dst_active": boolean
}
Examples:
$ timedatectl | jc --timedatectl -p
{
"local_time": "Tue 2020-03-10 17:53:21 PDT",
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
"rtc_time": "Wed 2020-03-11 00:53:21",
"time_zone": "America/Los_Angeles (PDT, -0700)",
"ntp_enabled": true,
"ntp_synchronized": true,
"rtc_in_local_tz": false,
"dst_active": true,
"epoch_utc": 1583888001
}
$ timedatectl | jc --timedatectl -p -r
{
"local_time": "Tue 2020-03-10 17:53:21 PDT",
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
"rtc_time": "Wed 2020-03-11 00:53:21",
"time_zone": "America/Los_Angeles (PDT, -0700)",
"ntp_enabled": "yes",
"ntp_synchronized": "yes",
"rtc_in_local_tz": "no",
"dst_active": "yes"
}
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.timedatectl.parse"></a>
2022-03-05 12:15:14 -08:00
### parse
2022-01-25 17:07:47 -08:00
2020-03-10 18:37:55 -07:00
```python
2022-01-25 17:07:47 -08:00
def parse(data, raw=False, quiet=False)
2020-03-10 18:37:55 -07:00
```
Main text parsing function
2022-01-25 18:03:34 -08:00
Parameters:
2020-03-10 18:37:55 -07:00
2022-01-25 18:03:34 -08:00
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
2020-03-10 18:37:55 -07:00
2022-01-25 18:03:34 -08:00
Returns:
2020-03-10 18:37:55 -07:00
2022-01-25 18:03:34 -08:00
Dictionary. Raw or processed structured data.
2020-03-10 18:37:55 -07:00
2022-01-25 19:18:54 -08:00
### Parser Information
Compatibility: linux
2022-02-07 15:44:54 -08:00
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)