Skip to content

Commit

Permalink
logging: leap-year issue. without a year, strptime() doesn't seem to …
Browse files Browse the repository at this point in the history
…assume it's this year., backport c104582
  • Loading branch information
AdSchellevis committed Feb 29, 2020
1 parent 2702445 commit e3774dd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/opnsense/scripts/systemhealth/queryLog.py
Expand Up @@ -88,7 +88,9 @@
if len(record['line']) > 15 and \
re.match(r'(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)', record['line'][7:15]):
# syslog format, strip timestamp and return actual log data
ts = datetime.datetime.strptime(record['line'][0:15], "%b %d %H:%M:%S")
ts = datetime.datetime.strptime(
"%s %s" % (startup_timestamp.year, record['line'][0:15]), "%Y %b %d %H:%M:%S"
)
ts = ts.replace(year=startup_timestamp.year)
if (startup_timestamp - ts).days < 0:
# likely previous year, (month for this year not reached yet)
Expand Down

0 comments on commit e3774dd

Please sign in to comment.