Skip to content

Commit

Permalink
Merge pull request #4 from isaacsanders/master
Browse files Browse the repository at this point in the history
Use the start month if the end month doesn't exist
  • Loading branch information
robintw committed Feb 6, 2015
2 parents 02df131 + 0050070 commit 0c7c5da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions daterangeparser/parse_date_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ def parse(text):
return (start_datetime, None)
else:
try:
if "month" not in res.end:
res.end["month"] = res.start["month"]
end_str = "%(day)s/%(month)s/%(year)s" % res.end
end_datetime = datetime.datetime.strptime(end_str, "%d/%m/%Y")
except ValueError:
Expand Down
1 change: 1 addition & 0 deletions daterangeparser/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class WorkingParsingTest(unittest.TestCase):
("Tuesday 29 May - Sat 2 June 2012", "29/5/2012", "2/6/2012"),
("1-9 Jul", "1/7/XXXX", "9/7/XXXX"),
("Tuesday 19th June - Wednesday 20th June 2013", "19/6/2013", "20/6/2013"),
("January 10th - 11th", "10/1/XXXX", "11/1/XXXX"),

# Different separators
("14--16th May", "14/5/XXXX", "16/5/XXXX"),
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Most date range formats that use specific dates (rather than 'tomorrow' or 'last
Examples that are known to work include:

- 27th-29th June 2010
- January 10th - 11th
- 30 May to 9th Aug
- 3rd Jan 1980 -- 2nd Jan 2013
- Wed 23 Jan -> Sat 16 February 2013
Expand Down Expand Up @@ -87,4 +88,4 @@ Fixed minor bugs, and bumped to stable release of version 1.0

0.6
^^^
First release with main functionality.
First release with main functionality.

0 comments on commit 0c7c5da

Please sign in to comment.