Skip to content

Commit

Permalink
Fixed #109: YearParseStyle was ignored in method parseDate
Browse files Browse the repository at this point in the history
  • Loading branch information
philiptzou committed Jul 30, 2015
1 parent be602b5 commit 207f817
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parsedatetime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def parseDate(self, dateString, sourceTime=None):
# if the year is not specified and the date has already
# passed, increment the year
if v3 == -1 and ((mth > d['m']) or (mth == d['m'] and dy > d['d'])):
yr = d['y'] + 1
yr = d['y'] + self.ptc.YearParseStyle
else:
yr = d['y']

Expand Down
9 changes: 9 additions & 0 deletions parsedatetime/tests/TestSimpleDateTimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ def testWordBoundaries(self):
phrase = '1 %sfoo' % keyword
self.assertExpectedResult(self.cal.parse(phrase, start), (target, 0))

def testYearParseStyle(self):
config = pdt.Constants()
config.YearParseStyle = 0
calendar = pdt.Calendar(config)
start = datetime.datetime(self.yr, self.mth, self.dy,
self.hr, self.mn, self.sec).timetuple()
target = datetime.datetime(self.yr, 7, 28,
self.hr, self.mn, self.sec).timetuple()
self.assertExpectedResult(calendar.parse('7/28', start), (target, 1))

# def testMonths(self):
#
Expand Down

0 comments on commit 207f817

Please sign in to comment.