Skip to content

Commit

Permalink
[V3] Fix the pattern in xs:date for offset
Browse files Browse the repository at this point in the history
We incorrectly did not group the offset for `+14:00` or `-14:00`, so it
could be directly concatenated to the year in `xs:date`'s.

This patch fixes the issue, so the incorrect dates are correctly
recognized.
  • Loading branch information
mristin committed Mar 6, 2024
1 parent 04a99a5 commit d9e4d51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aas_core_meta/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def matches_xs_date(text: str) -> bool:
month_frag = f"((0[1-9])|(1[0-2]))"
day_frag = f"((0[1-9])|([12]{digit})|(3[01]))"
minute_frag = f"[0-5]{digit}"
timezone_frag = rf"(Z|(\+|-)(0{digit}|1[0-3]):{minute_frag}|14:00)"
timezone_frag = rf"(Z|(\+|-)((0{digit}|1[0-3]):{minute_frag}|14:00))"
date_lexical_rep = f"{year_frag}-{month_frag}-{day_frag}{timezone_frag}?"

pattern = f"^{date_lexical_rep}$"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ def test_date_with_invalid_offset(self) -> None:
def test_date_with_unexpected_suffix(self) -> None:
assert not v3.matches_xs_date("2022-04-01unexpected")

def test_with_unexpected_concatenated_time_zone(self) -> None:
assert not v3.matches_xs_date("0705-04-1014:00")


class Test_matches_xs_date_time(unittest.TestCase):
def test_empty(self) -> None:
Expand Down

0 comments on commit d9e4d51

Please sign in to comment.