diff --git a/jc/parsers/date.py b/jc/parsers/date.py index d09eed5d..df710f69 100644 --- a/jc/parsers/date.py +++ b/jc/parsers/date.py @@ -83,7 +83,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '2.2' + version = '2.3' description = '`date` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -168,7 +168,7 @@ def parse(data, raw=False, quiet=False): dt = None dt_utc = None - timestamp = jc.utils.timestamp(data) + timestamp = jc.utils.timestamp(data, format_hint=(1000, 6000, 7000)) if timestamp.naive: dt = datetime.fromtimestamp(timestamp.naive) if timestamp.utc: diff --git a/jc/parsers/dig.py b/jc/parsers/dig.py index b7d32d50..0af225b1 100644 --- a/jc/parsers/dig.py +++ b/jc/parsers/dig.py @@ -327,7 +327,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '2.2' + version = '2.3' description = '`dig` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -384,7 +384,7 @@ def _process(proc_data): auth['ttl'] = jc.utils.convert_to_int(auth['ttl']) if 'when' in entry: - ts = jc.utils.timestamp(entry['when']) + ts = jc.utils.timestamp(entry['when'], format_hint=(1000, 7000)) entry['when_epoch'] = ts.naive entry['when_epoch_utc'] = ts.utc diff --git a/jc/parsers/dir.py b/jc/parsers/dir.py index 5c65750d..f9f168b1 100644 --- a/jc/parsers/dir.py +++ b/jc/parsers/dir.py @@ -126,7 +126,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.4' + version = '1.5' description = '`dir` command parser' author = 'Rasheed Elsaleh' author_email = 'rasheed@rebelliondefense.com' @@ -152,7 +152,7 @@ def _process(proc_data): # add timestamps if 'date' in entry and 'time' in entry: dt = entry['date'] + ' ' + entry['time'] - timestamp = jc.utils.timestamp(dt) + timestamp = jc.utils.timestamp(dt, format_hint=(1600,)) entry['epoch'] = timestamp.naive # add ints diff --git a/jc/parsers/ls.py b/jc/parsers/ls.py index e497c194..fba2c2a4 100644 --- a/jc/parsers/ls.py +++ b/jc/parsers/ls.py @@ -122,7 +122,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.10' + version = '1.11' description = '`ls` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -154,7 +154,7 @@ def _process(proc_data): if 'date' in entry: # to speed up processing only try to convert the date if it's not the default format if not re.match(r'[a-zA-Z]{3}\s{1,2}\d{1,2}\s{1,2}[0-9:]{4,5}', entry['date']): - ts = jc.utils.timestamp(entry['date']) + ts = jc.utils.timestamp(entry['date'], format_hint=(7200,)) entry['epoch'] = ts.naive entry['epoch_utc'] = ts.utc diff --git a/jc/parsers/ls_s.py b/jc/parsers/ls_s.py index 55bb6154..3f0fef0e 100644 --- a/jc/parsers/ls_s.py +++ b/jc/parsers/ls_s.py @@ -118,7 +118,7 @@ def _process(proc_data): if 'date' in proc_data: # to speed up processing only try to convert the date if it's not the default format if not re.match(r'[a-zA-Z]{3}\s{1,2}\d{1,2}\s{1,2}[0-9:]{4,5}', proc_data['date']): - ts = jc.utils.timestamp(proc_data['date']) + ts = jc.utils.timestamp(proc_data['date'], format_hint=(7200,)) proc_data['epoch'] = ts.naive proc_data['epoch_utc'] = ts.utc diff --git a/jc/parsers/rpm_qi.py b/jc/parsers/rpm_qi.py index a0e6e689..2a6a81dd 100644 --- a/jc/parsers/rpm_qi.py +++ b/jc/parsers/rpm_qi.py @@ -166,7 +166,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.4' + version = '1.5' description = '`rpm -qi` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -197,12 +197,12 @@ def _process(proc_data): entry[key] = jc.utils.convert_to_int(entry[key]) if 'build_date' in entry: - timestamp = jc.utils.timestamp(entry['build_date']) + timestamp = jc.utils.timestamp(entry['build_date'], format_hint=(3000,)) entry['build_epoch'] = timestamp.naive entry['build_epoch_utc'] = timestamp.utc if 'install_date' in entry: - timestamp = jc.utils.timestamp(entry['install_date']) + timestamp = jc.utils.timestamp(entry['install_date'], format_hint=(3000,)) entry['install_date_epoch'] = timestamp.naive entry['install_date_epoch_utc'] = timestamp.utc diff --git a/jc/parsers/rsync.py b/jc/parsers/rsync.py index 084e37ed..2ab0ea57 100644 --- a/jc/parsers/rsync.py +++ b/jc/parsers/rsync.py @@ -185,7 +185,7 @@ def _process(proc_data: List[Dict]) -> List[Dict]: if 'date' in entry and 'time' in entry: date = entry['date'].replace('/', '-') date_time = f'{date} {entry["time"]}' - ts = jc.utils.timestamp(date_time) + ts = jc.utils.timestamp(date_time, format_hint=(7250,)) entry['epoch'] = ts.naive return proc_data diff --git a/jc/parsers/rsync_s.py b/jc/parsers/rsync_s.py index bd59151c..d6b697ff 100644 --- a/jc/parsers/rsync_s.py +++ b/jc/parsers/rsync_s.py @@ -134,7 +134,7 @@ def _process(proc_data: Dict) -> Dict: if 'date' in proc_data and 'time' in proc_data: date = proc_data['date'].replace('/', '-') date_time = f'{date} {proc_data["time"]}' - ts = jc.utils.timestamp(date_time) + ts = jc.utils.timestamp(date_time, format_hint=(7250,)) proc_data['epoch'] = ts.naive return proc_data diff --git a/jc/parsers/stat.py b/jc/parsers/stat.py index 187c018e..af6bbd33 100644 --- a/jc/parsers/stat.py +++ b/jc/parsers/stat.py @@ -176,7 +176,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.10' + version = '1.11' description = '`stat` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -213,7 +213,7 @@ def _process(proc_data): if key in entry: if entry[key] == '-': entry[key] = None - ts = jc.utils.timestamp(entry[key]) + ts = jc.utils.timestamp(entry[key], format_hint=(7100, 7200)) entry[key + '_epoch'] = ts.naive entry[key + '_epoch_utc'] = ts.utc diff --git a/jc/parsers/stat_s.py b/jc/parsers/stat_s.py index 2632f24c..33b1fa78 100644 --- a/jc/parsers/stat_s.py +++ b/jc/parsers/stat_s.py @@ -126,7 +126,7 @@ def _process(proc_data): if key in proc_data: if proc_data[key] == '-': proc_data[key] = None - ts = jc.utils.timestamp(proc_data[key]) + ts = jc.utils.timestamp(proc_data[key], format_hint=(7100, 7200)) proc_data[key + '_epoch'] = ts.naive proc_data[key + '_epoch_utc'] = ts.utc diff --git a/jc/parsers/systeminfo.py b/jc/parsers/systeminfo.py index 3cc03a2f..dfcd1ba8 100644 --- a/jc/parsers/systeminfo.py +++ b/jc/parsers/systeminfo.py @@ -217,7 +217,7 @@ import jc.utils class info: """Provides parser metadata (version, author, etc.)""" - version = "1.1" + version = "1.2" description = "`systeminfo` command parser" author = "Jon Smith" author_email = "jon@rebelliondefense.com" @@ -279,8 +279,10 @@ def _process(proc_data): # to: (UTC-0800) tz_fields = tz.split() tz = " " + tz_fields[0].replace(":", "") - proc_data[key + '_epoch'] = jc.utils.timestamp(f"{proc_data.get(key)}{tz}").naive - proc_data[key + '_epoch_utc'] = jc.utils.timestamp(f"{proc_data.get(key)}{tz}").utc + ts_formats = (1700, 1705, 1710) + ts = jc.utils.timestamp(f"{proc_data.get(key)}{tz}", format_hint=ts_formats) + proc_data[key + '_epoch'] = ts.naive + proc_data[key + '_epoch_utc'] = ts.utc hyperv_key = "hyperv_requirements" hyperv_subkey_list = [ diff --git a/jc/parsers/timedatectl.py b/jc/parsers/timedatectl.py index 0d58c527..5a5d670a 100644 --- a/jc/parsers/timedatectl.py +++ b/jc/parsers/timedatectl.py @@ -69,7 +69,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.5' + version = '1.6' description = '`timedatectl status` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -99,7 +99,7 @@ def _process(proc_data): proc_data[key] = jc.utils.convert_to_bool(proc_data[key]) if 'universal_time' in proc_data: - ts = jc.utils.timestamp(proc_data['universal_time']) + ts = jc.utils.timestamp(proc_data['universal_time'], format_hint=(7300,)) proc_data['epoch_utc'] = ts.utc return proc_data diff --git a/jc/parsers/upower.py b/jc/parsers/upower.py index 0a3df60d..b6508231 100644 --- a/jc/parsers/upower.py +++ b/jc/parsers/upower.py @@ -203,7 +203,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.3' + version = '1.4' description = '`upower` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -234,7 +234,8 @@ def _process(proc_data): entry['updated_seconds_ago'] = jc.utils.convert_to_int(updated_list[-3]) if entry['updated']: - ts = jc.utils.timestamp(entry['updated']) + hints = (1000, 2000, 3000, 4000, 5000, 8000, 8100) + ts = jc.utils.timestamp(entry['updated'], format_hint=hints) entry['updated_epoch'] = ts.naive entry['updated_epoch_utc'] = ts.utc diff --git a/jc/parsers/vmstat.py b/jc/parsers/vmstat.py index a456e0e4..f39a5b71 100644 --- a/jc/parsers/vmstat.py +++ b/jc/parsers/vmstat.py @@ -131,7 +131,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.1' + version = '1.2' description = '`vmstat` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -169,7 +169,8 @@ def _process(proc_data): entry[key] = jc.utils.convert_to_int(entry[key]) if entry['timestamp']: - ts = jc.utils.timestamp(f'{entry["timestamp"]} {entry["timezone"]}') + fmt_hint = (7250, 7255) + ts = jc.utils.timestamp(f'{entry["timestamp"]} {entry["timezone"]}', format_hint=fmt_hint) entry['epoch'] = ts.naive entry['epoch_utc'] = ts.utc diff --git a/jc/parsers/vmstat_s.py b/jc/parsers/vmstat_s.py index a2e7871f..a6438e6c 100644 --- a/jc/parsers/vmstat_s.py +++ b/jc/parsers/vmstat_s.py @@ -145,7 +145,8 @@ def _process(proc_data): proc_data[key] = jc.utils.convert_to_int(proc_data[key]) if proc_data['timestamp']: - ts = jc.utils.timestamp(f'{proc_data["timestamp"]} {proc_data["timezone"]}') + fmt_hint = (7250, 7255) + ts = jc.utils.timestamp(f'{proc_data["timestamp"]} {proc_data["timezone"]}', format_hint=fmt_hint) proc_data['epoch'] = ts.naive proc_data['epoch_utc'] = ts.utc diff --git a/jc/parsers/who.py b/jc/parsers/who.py index 541df5d1..c66d4003 100644 --- a/jc/parsers/who.py +++ b/jc/parsers/who.py @@ -141,7 +141,7 @@ import jc.utils class info(): """Provides parser metadata (version, author, etc.)""" - version = '1.5' + version = '1.6' description = '`who` command parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -171,7 +171,7 @@ def _process(proc_data): entry[key] = jc.utils.convert_to_int(entry[key]) if 'time' in entry: - ts = jc.utils.timestamp(entry['time']) + ts = jc.utils.timestamp(entry['time'], format_hint=(1500,)) entry['epoch'] = ts.naive return proc_data