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:
@ -155,10 +155,10 @@ def process(proc_data):
|
|||||||
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'])
|
||||||
|
Reference in New Issue
Block a user