Skip to content

Commit cfa8603

Browse files
committed
[parser] Allow one-digit days
1 parent 942b94b commit cfa8603

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

maillogger/parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Dict, Optional
55

66

7-
REGEX = r'(?P<month>[A-Z][a-z]{2}) (?P<day>[0-9]{,2}) ' \
7+
REGEX = r'(?P<month>[A-Z][a-z]{2}) +(?P<day>[0-9]{,2}) ' \
88
+ r'(?P<time>[0-9]{2}:[0-9]{2}:[0-9]{2}) (?P<hostname>[A-Za-z0-9-]+) postfix/[a-z/]+\[[0-9]+\]: ' \
99
+ r'(?P<mail_id>[A-Z0-9]+): to=<(?P<to_address>.*@.*)>, ' \
1010
+ r'relay=(?P<relay>.*), delay=(?P<delay>[0-9.]+), ' \
@@ -74,5 +74,6 @@ def to_dict(self) -> ParseResultType:
7474

7575
@staticmethod
7676
def convert2dateime(month: str, day: str, time: str) -> str:
77+
day = day.rjust(2, '0')
7778
tmp = datetime.strptime(f'{month}{day}{time}', '%b%d%H:%M:%S')
7879
return tmp.replace(year=datetime.now().year).strftime('%Y%m%d%H%M%S')

0 commit comments

Comments
 (0)