fix incorrect prasing of timestamps

This commit is contained in:
Rossen Georgiev 2014-12-27 20:20:54 +00:00
parent 5a7da98f2d
commit d57c368aef
1 changed files with 12 additions and 19 deletions

View File

@ -118,29 +118,22 @@ def parse(raw_sentence):
parsed.update({'raw_timestamp': rawts})
timestamp = 0
try:
if form in "hz/":
if form == 'h': # zulu hhmmss format
timestamp = utc.strptime(
"%s %s %s %s" % (utc.year, utc.month, utc.day, ts),
"%Y %m %d %H%M%S"
)
elif form == 'z': # zulu ddhhss format
timestamp = utc.strptime(
"%s %s %s" % (utc.year, utc.month, ts),
"%Y %m %d%M%S"
)
elif form == '/': # '/' local ddhhss format
timestamp = utc.strptime(
"%s %s %s" % (utc.year, utc.month, ts),
"%Y %m %d%M%S"
)
# zulu hhmmss format
if form == 'h':
timestamp = "%s%s%s%s" % (utc.year, utc.month, utc.day, ts)
# zulu ddhhmm format
# '/' local ddhhmm format
elif form in 'z/':
timestamp = "%s%s%s%s" % (utc.year, utc.month, ts, utc.second)
timestamp = utc.strptime(timestamp, "%Y%m%d%H%M%S")
timestamp = time.mktime(timestamp.timetuple())
else:
timestamp = 0
except:
timestamp = 0
except Exception as exp:
logger.debug(exp)
pass
parsed.update({'timestamp': int(timestamp)})