1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

use parse_datetime_to_timestamp function instead of custom format string

This commit is contained in:
Kelly Brazil
2021-03-24 21:51:43 -07:00
parent 90c7e18e5f
commit ed7eb0983a

View File

@ -154,11 +154,11 @@ def process(proc_data):
if 'logout' in entry and entry['logout'] == 'gone_-_no_logout': if 'logout' in entry and entry['logout'] == 'gone_-_no_logout':
entry['logout'] = 'gone - no logout' entry['logout'] = 'gone - no logout'
if 'login' in entry and re.match(r'.*\d\d:\d\d:\d\d \d\d\d\d.*',entry['login']): if 'login' in entry and re.match(r'.*\d\d:\d\d:\d\d \d\d\d\d.*', entry['login']):
entry['login_epoch'] = int(datetime.strptime(entry['login'], '%a %b %d %H:%M:%S %Y').strftime('%s')) entry['login_epoch'] = jc.utils.parse_datetime_to_timestamp(entry['login'])['timestamp_naive']
if 'logout' in entry and re.match(r'.*\d\d:\d\d:\d\d \d\d\d\d.*',entry['logout']): if 'logout' in entry and re.match(r'.*\d\d:\d\d:\d\d \d\d\d\d.*', entry['logout']):
entry['logout_epoch'] = int(datetime.strptime(entry['logout'], '%a %b %d %H:%M:%S %Y').strftime('%s')) entry['logout_epoch'] = jc.utils.parse_datetime_to_timestamp(entry['logout'])['timestamp_naive']
if 'login_epoch' in entry and 'logout_epoch' in entry: if 'login_epoch' in entry and 'logout_epoch' in entry:
entry['duration_seconds'] = int(entry['logout_epoch']) - int(entry['login_epoch']) entry['duration_seconds'] = int(entry['logout_epoch']) - int(entry['login_epoch'])