Try to fix UTC problem
This commit is contained in:
parent
6d62f21373
commit
1a5f65bdc2
|
@ -23,8 +23,7 @@ log_format = '$server_name:$server_port $remote_addr - $remote_user [$time_local
|
|||
'"$http_referer" "$http_user_agent"'
|
||||
|
||||
# Time format used in log format
|
||||
# TOFIX UTC
|
||||
time_format = '%d/%b/%Y:%H:%M:%S +0100'
|
||||
time_format = '%d/%b/%Y:%H:%M:%S %z'
|
||||
|
||||
# Hooks that are loaded at runtime (only set names without path and extensions)
|
||||
pre_analysis_hooks = []
|
||||
|
|
19
iwla.py
19
iwla.py
|
@ -310,7 +310,22 @@ class IWLA(object):
|
|||
return True
|
||||
|
||||
def _decodeTime(self, hit):
|
||||
hit['time_decoded'] = time.strptime(hit['time_local'], conf.time_format)
|
||||
try:
|
||||
hit['time_decoded'] = time.strptime(hit['time_local'], conf.time_format)
|
||||
except ValueError, e:
|
||||
if sys.version_info < (3, 2):
|
||||
# Try without UTC value at the end (%z not recognized)
|
||||
gmt_offset_str = hit['time_local'][-5:]
|
||||
gmt_offset_hours = int(gmt_offset_str[1:3])*60*60
|
||||
gmt_offset_minutes = int(gmt_offset_str[3:5])*60
|
||||
gmt_offset = gmt_offset_hours + gmt_offset_minutes
|
||||
hit['time_decoded'] = time.strptime(hit['time_local'][:-6], conf.time_format[:-3])
|
||||
if gmt_offset_str[0] == '+':
|
||||
hit['time_decoded'] = time.localtime(time.mktime(hit['time_decoded'])+gmt_offset)
|
||||
else:
|
||||
hit['time_decoded'] = time.localtime(time.mktime(hit['time_decoded'])-gmt_offset)
|
||||
else:
|
||||
raise e
|
||||
return hit['time_decoded']
|
||||
|
||||
def getDisplayIndex(self):
|
||||
|
@ -583,7 +598,7 @@ class IWLA(object):
|
|||
print '==> Load previous database'
|
||||
|
||||
self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta()
|
||||
if 'last_time' in self.meta_infos.keys():
|
||||
if self.meta_infos['last_time']:
|
||||
self.current_analysis = self._deserialize(self.getDBFilename(self.meta_infos['last_time'])) or self._clearVisits()
|
||||
else:
|
||||
self._clearVisits()
|
||||
|
|
Loading…
Reference in New Issue
Block a user