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 inconsistencies in date check #2070

Merged
merged 1 commit into from
Nov 18, 2023
Merged
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
10 changes: 5 additions & 5 deletions plugins/Date.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def init(self, logger):
def convert2date(self, string):
try:
date = dateutil.parser.parse(string, default=self.default_date)
if date.year != 9999:
if date.year < 3000:
return date
except (ValueError, TypeError, OverflowError):
pass
Expand All @@ -59,11 +59,11 @@ def check(self, string):
if len(string) == 0:
return True
if string[0] == '~':
return self.check(string[1:])
return len(string) > 1 and self.check(string[1:])
if string[-1] == 's':
return self.check(string[:-1])
return len(string) > 1 and self.check(string[:-1])
if string[-3:] == ' BC' or string[-3:] == ' AD':
return self.check(string[:-3])
return len(string) > 3 and self.check(string[:-3])
if len(string) == 4 and self.Year.match(string):
return True
if len(string) == 10 and (self.Day1.match(string) or self.Day2.match(string)):
Expand Down Expand Up @@ -111,7 +111,7 @@ def test(self):

assert not a.node(None, {"date":"yes", "amenity":"clock"}), ("date=yes")

for d in ["yes", "XVI", "p", "0000", "9999", "Ca9", "1914..9999", "2014..Ca09"]:
for d in ["yes", "XVI", "p", "0000", "9999", "Ca9", "1914..9999", "2014..Ca09", "7000", "~"]:
self.check_err(a.node(None, {"date":d}), ("date={0}".format(d)))
self.check_err(a.way(None, {"date":d}, None), ("date={0}".format(d)))
self.check_err(a.relation(None, {"date":d}, None), ("date={0}".format(d)))
Loading