diff --git a/parsedatetime/__init__.py b/parsedatetime/__init__.py index 26de580..2e1b9bd 100644 --- a/parsedatetime/__init__.py +++ b/parsedatetime/__init__.py @@ -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: @@ -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) diff --git a/tests/TestComplexDateTimes.py b/tests/TestComplexDateTimes.py index f40bbe1..56132ed 100644 --- a/tests/TestComplexDateTimes.py +++ b/tests/TestComplexDateTimes.py @@ -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()