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

fix date interpretation when day is also provided (#165) #178

Merged
merged 2 commits into from
Aug 23, 2016
Merged
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
5 changes: 4 additions & 1 deletion parsedatetime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,9 @@ def _partialParseWeekday(self, s, sourceTime):
parseStr = None
chunk1 = chunk2 = ''

ctx = self.currentContext
log.debug('eval %s with context - %s, %s', s, ctx.hasDate, ctx.hasTime)

# Weekday
m = self.ptc.CRE_WEEKDAY.search(s)
if m is not None:
Expand All @@ -1592,7 +1595,7 @@ def _partialParseWeekday(self, s, sourceTime):
parseStr = s
s = ''

if parseStr:
if parseStr and not ctx.hasDate:
debug and log.debug(
'found (weekday) [%s][%s][%s]', parseStr, chunk1, chunk2)
sourceTime = self._evalWeekday(parseStr, sourceTime)
Expand Down
6 changes: 6 additions & 0 deletions tests/TestComplexDateTimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ def testDates(self):
self.assertExpectedResult(
self.cal.parse('August 22nd 3:26 am', start), (target, 3))

def testDatesWithDay(self):
start = datetime(
self.yr, self.mth, self.dy, self.hr, self.mn, self.sec).timetuple()
target = datetime(2016, 8, 23, 17, 0, 0).timetuple()
self.assertExpectedResult(
self.cal.parse('tuesday august 23nd 2016 at 5pm', start), (target, 3))

if __name__ == "__main__":
unittest.main()