Commit bd70ec11 authored by Ad Schellevis's avatar Ad Schellevis

(network insight) export in local time

parent 9c1387f4
...@@ -30,12 +30,11 @@ ...@@ -30,12 +30,11 @@
""" """
import time import time
import datetime import datetime
from dateutil.tz import tzlocal
import pytz
import os import os
import sys import sys
import ujson
sys.path.insert(0, "/usr/local/opnsense/site-python") sys.path.insert(0, "/usr/local/opnsense/site-python")
from lib.parse import parse_flow
from lib.aggregate import BaseFlowAggregator
import lib.aggregates import lib.aggregates
import params import params
...@@ -75,6 +74,8 @@ if valid_params: ...@@ -75,6 +74,8 @@ if valid_params:
if not record[item]: if not record[item]:
line.append("") line.append("")
if type(record[item]) == datetime.datetime: if type(record[item]) == datetime.datetime:
# dates are stored in utc, return in timezone configured on this machine
record[item] = record[item].replace(tzinfo=pytz.utc).astimezone(tzlocal())
line.append('%s+00:00'%record[item].strftime('%Y/%m/%d %H:%M:%S')) line.append('%s+00:00'%record[item].strftime('%Y/%m/%d %H:%M:%S'))
elif type(record[item]) == float: elif type(record[item]) == float:
line.append('%.4f' % record[item]) line.append('%.4f' % record[item])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment