Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pendulum/parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
# Date (optional)
"^"
"(?P<date>"
" (?P<classic>" # Classic date (YYYY-MM-DD)
" (?P<classic>" # Classic date (YYYY:MM:DD) or (YYYY-MM-DD) or (YYYY/MM/DD)
" (?P<year>\d{4})" # Year
" (?P<monthday>"
" (?P<monthsep>[/:])?(?P<month>\d{2})" # Month (optional)
" ((?P<daysep>[/:])?(?P<day>\d{2}))" # Day (optional)
" (?P<monthsep>[/:-])?(?P<month>\d{1,2})" # Month (optional)
" ((?P<daysep>[/:-])?(?P<day>\d{1,2}))?" # Day (optional)
" )?"
" )"
")?"
Expand Down Expand Up @@ -160,7 +160,7 @@ def _parse_common(text, **options):
day = int(m.group("month"))
else:
month = int(m.group("month"))
day = int(m.group("day"))
day = int(m.group("day") or 1)

if not m.group("time"):
return date(year, month, day)
Expand Down
4 changes: 4 additions & 0 deletions tests/parsing/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,3 +680,7 @@ def test_exif_edge_case():
assert 15 == parsed.hour
assert 45 == parsed.minute
assert 28 == parsed.second

def test_month_padding():
# This shouldn't raise an exceptionf
pendulum.parse('2016-7')