Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix,added test case, issue no. 1299 by @priyambajpai22 #1302

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Expand Up @@ -95,6 +95,7 @@ switch, and thus all their contributions are dual-licensed.
- Pavel Ponomarev <comrad.awsum@MASKED>
- Peter Bieringer <pb@MASKED>
- Pierre Gergondet <pierre.gergondet@MASKED> (gh: @gergondet) **D**
- Priyam Bajpai <priyambajpai302@gmial.com> (gh: @priyambajpai22) **D**
- Quentin Pradet <quentin@MASKED>
- Raymond Cha (gh: @weatherpattern) **D**
- Ridhi Mahajan <ridhikmahajan@MASKED> **D**
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1299.bugfix.rst
@@ -0,0 +1 @@
Fixed issue where {added another condition in _parser.py for bad padding .previously parser.parse("January15,7626") giving the result -> 2023-01-15 00:00:00 now its fixed,}. Reported by @lucasabr (gh issue #1299). Fixed by @priyambajpai22 (gh pr #1302).
5 changes: 5 additions & 0 deletions src/dateutil/parser/_parser.py
Expand Up @@ -140,6 +140,11 @@ def get_token(self):
# numbers until we find something that doesn't fit.
if self.isnum(nextchar):
token += nextchar

elif nextchar=="," and len(token) >= 2:
token += nextchar
state = '0.'
seenletters=True
elif nextchar == '.' or (nextchar == ',' and len(token) >= 2):
token += nextchar
state = '0.'
Expand Down
5 changes: 5 additions & 0 deletions tests/test_parser.py
Expand Up @@ -184,6 +184,11 @@ def test_parse_yearfirst(sep):
result = parse(dstr, yearfirst=True)
assert result == expected

@pytest.mark.parametrize('dstr,expected',[('January15,7626',datetime(2023, 1, 15, 0, 0))])
def test_parse_without_padding_date(dstr,expected):
result=parse(dstr)
assert result==expected


@pytest.mark.parametrize('dstr,expected', [
("Thu Sep 25 10:36:28 BRST 2003", datetime(2003, 9, 25, 10, 36, 28)),
Expand Down