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

Bug fix/560: YY maps 2018 to 20 #580

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions arrow/arrow.py
Expand Up @@ -18,6 +18,7 @@

from arrow import util, locales, parser, formatter

#test

class Arrow(object):
'''An :class:`Arrow <arrow.arrow.Arrow>` object.
Expand Down
4 changes: 4 additions & 0 deletions arrow/parser.py
Expand Up @@ -176,6 +176,10 @@ def parse(self, string, fmt):
if match is None:
raise ParserError('Failed to match \'{}\' when parsing \'{}\''
.format(fmt_pattern_re.pattern, string))

if match.end() != len(string) and 'Z' not in string:
raise ParserError('BUG FIX: Failed to match \'{}\' when parsing \'{}\''
.format(fmt_pattern_re.pattern, string))
parts = {}
for token in fmt_tokens:
if token == 'Do':
Expand Down
10 changes: 10 additions & 0 deletions tests/parser_tests.py
Expand Up @@ -272,6 +272,16 @@ def test_try_timestamp(self):
assertEqual(parser.DateTimeParser._try_timestamp('1'), 1)
assertEqual(parser.DateTimeParser._try_timestamp('abc'), None)

def test_too_many_year_digits_YYYY(self):
with assertRaises(parser.ParserError):
self.parser.parse('01 June 123456789101112', 'DD MMMM YYYY')

def test_too_many_year_digits_YY(self):
with assertRaises(parser.ParserError):
self.parser.parse('01 June 2018', 'DD MMMM YY')




class DateTimeParserRegexTests(Chai):

Expand Down