diff --git a/parsedatetime/__init__.py b/parsedatetime/__init__.py index 88381a6..16ffe95 100644 --- a/parsedatetime/__init__.py +++ b/parsedatetime/__init__.py @@ -2576,19 +2576,18 @@ def _buildOffsets(offsetDict, localeData, indexStart): else: self.RE_TIMEHMS2 += r'\b' - # Always support common . and - separators - dateSeps = ''.join(re.escape(s) - for s in self.locale.dateSep + ['-', '.']) + dateSeps = re.escape(''.join(self.locale.dateSep)) + # Add - as a date separator only for yyyy-mm-dd format self.RE_DATE = r'''([\s(\["'-]|^) (?P \d\d?[{0}]\d\d?(?:[{0}]\d\d(?:\d\d)?)? | - \d{{4}}[{0}]\d\d?[{0}]\d\d? + \d{{4}}[{0}-]\d\d?[{0}-]\d\d? ) \b'''.format(dateSeps) - self.RE_DATE2 = r'[{0}]'.format(dateSeps) + self.RE_DATE2 = r'[{0}-]'.format(dateSeps) assert 'dayoffsets' in self.locale.re_values diff --git a/parsedatetime/pdt_locales/en_US.py b/parsedatetime/pdt_locales/en_US.py index 12584e5..8989d85 100644 --- a/parsedatetime/pdt_locales/en_US.py +++ b/parsedatetime/pdt_locales/en_US.py @@ -4,4 +4,5 @@ # don't use an unicode string localeID = 'en_US' +dateSep = ['/'] uses24 = False diff --git a/tests/TestAustralianLocale.py b/tests/TestAustralianLocale.py index f3fd34b..37c1db2 100644 --- a/tests/TestAustralianLocale.py +++ b/tests/TestAustralianLocale.py @@ -82,8 +82,6 @@ def testDates(self): self.cal.parse('25-08-2006', start), (target, 1)) self.assertExpectedResult( self.cal.parse('25/08/2006', start), (target, 1)) - self.assertExpectedResult( - self.cal.parse('25.08.2006', start), (target, 1)) self.assertExpectedResult( self.cal.parse('25-8-06', start), (target, 1)) self.assertExpectedResult( @@ -98,7 +96,6 @@ def testDates(self): self.assertExpectedResult(self.cal.parse('25-8', start), (target, 1)) self.assertExpectedResult(self.cal.parse('25/8', start), (target, 1)) - self.assertExpectedResult(self.cal.parse('25.8', start), (target, 1)) self.assertExpectedResult(self.cal.parse('25-08', start), (target, 1)) self.assertExpectedResult(self.cal.parse('25/08', start), (target, 1))