Support dates without without high-precision part.

When parsing postfix logs to build stats and message history
This commit is contained in:
Antoine Nguyen
2025-07-31 18:04:06 +02:00
parent 6023dc6a2e
commit b971bcf19f
@@ -78,6 +78,7 @@ class LogParser:
# set up regular expression
self._date_expressions = [
r"(?P<month>\w+)\s+(?P<day>\d+)\s+(?P<hour>\d+):(?P<min>\d+):(?P<sec>\d+)(?P<eol>.*)", # noqa
r"(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)T(?P<hour>\d+):(?P<min>\d+):(?P<sec>\d+)[\+\-]\d+:\d+(?P<eol>.*)", # noqa
r"(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)T(?P<hour>\d+):(?P<min>\d+):(?P<sec>\d+)\.\d+[\+\-]\d+:\d+(?P<eol>.*)", # noqa
]
self._date_expressions = [re.compile(v) for v in self._date_expressions]