Skip to content

Commit

Permalink
Merge pull request #7 from shade33/master
Browse files Browse the repository at this point in the history
Fixed bug with 00000
  • Loading branch information
robintw committed Aug 11, 2015
2 parents 2cc44e8 + 327fc91 commit 914747e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions daterangeparser/parse_date_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
import datetime
import calendar

def check_day(tokens):
"""Converts to int and checks a day number, ensuring it is > 1 and < 31.

def check_day(tokens=None):
"""

Converts to int and checks a day number, ensuring it is > 1 and < 31.
"""
if not tokens:
raise ParseException("Couldn't parse resulting datetime")

t = int(tokens[0])
if t >= 1 and t <= 31:
return t
else:
raise ParseException()
raise ParseException("Couldn't parse resulting datetime")

def month_to_number(tokens):
"""Converts a given month in string format to the equivalent month number.
Expand All @@ -52,6 +55,7 @@ def month_to_number(tokens):
'aug' : 8,
'august' : 8,
'sep' : 9,
'sept' : 9,
'september' : 9,
'oct' : 10,
'october' : 10,
Expand Down
1 change: 1 addition & 0 deletions daterangeparser/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class FailingParsings(unittest.TestCase):
"Turs 13th May 1998",
"18 Octobre 2004",
"to",
"00000",
]

def runTest(self):
Expand Down

0 comments on commit 914747e

Please sign in to comment.