Skip to content

Commit

Permalink
增加时间格式支持
Browse files Browse the repository at this point in the history
  • Loading branch information
kusen-alpha committed Aug 28, 2024
1 parent 29bbf57 commit ba7fcea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gggdtparser/dtparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _get_default_regex_list(cls, lang, extract_accurately):
def match_and_parse(cls, string_datetime, regex_list,
result_accurately, max_datetime,
min_datetime, base_datetime):
for regex in regex_list:
for index, regex in enumerate(regex_list):
try:
match_obj = regex.search(string_datetime)
except (ValueError, re.error) as e:
Expand Down
2 changes: 2 additions & 0 deletions gggdtparser/langs/en.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
r"(?P<m>\d{1,2})\s*[月]?\s*(?P<d>\d{1,2})\s*(?P<Y>\d{4})",
# 25 10 2021
r"(?P<d>\d{1,2})\s*(?P<m>\d{1,2})\s*(?P<Y>\d{4})",
# 23 December, 2022 / 15:20
r"(?P<d>\d{1,2})\s*(?P<m>\d{1,2})\s*[月]?\s*,?\s*(?P<Y>\d{4})\s*/?\s*(?P<H>\d{1,2}):(?P<M>\d{1,2})",
r"(?P<m>\d{1,2})\s*(?P<Y>\d{4})", # 10 2021
r"(?P<bS>\d+)\s*seconds?\s*(ago)?",
r"(?P<bM>\d+)\s*m\s*ago",
Expand Down
4 changes: 2 additions & 2 deletions gggdtparser/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@


import datetime
from ..dtparser import parse
from ..dtparser import check
from gggdtparser.dtparser import parse
from gggdtparser.dtparser import check


def test(test_string_datetime):
Expand Down

0 comments on commit ba7fcea

Please sign in to comment.