Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions sdk/basyx/aas/model/datatypes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 the Eclipse BaSyx Authors
# Copyright (c) 2026 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down Expand Up @@ -604,7 +604,8 @@ def _parse_xsd_date(value: str) -> Date:
if not match:
raise ValueError("Value is not a valid XSD date string")
if match[1]:
raise ValueError("Negative Dates are not supported by Python")
raise NotImplementedError("Negative dates are not supported: Python stdlib datetime requires year >= 1. "
"Report at https://github.com/eclipse-basyx/basyx-python-sdk/issues")
return Date(int(match[2]), int(match[3]), int(match[4]), _parse_xsd_date_tzinfo(match[5]))


Expand All @@ -613,7 +614,8 @@ def _parse_xsd_datetime(value: str) -> DateTime:
if not match:
raise ValueError("Value is not a valid XSD datetime string")
if match[1]:
raise ValueError("Negative Dates are not supported by Python")
raise NotImplementedError("Negative dates are not supported: Python stdlib datetime requires year >= 1. "
"Report at https://github.com/eclipse-basyx/basyx-python-sdk/issues")
microseconds = int(float(match[8]) * 1e6) if match[8] else 0
return DateTime(int(match[2]), int(match[3]), int(match[4]), int(match[5]), int(match[6]), int(match[7]),
microseconds, _parse_xsd_date_tzinfo(match[9]))
Expand Down
6 changes: 5 additions & 1 deletion sdk/test/model/test_datatypes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2025 the Eclipse BaSyx Authors
# Copyright (c) 2026 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down Expand Up @@ -143,6 +143,8 @@ def test_parse_date(self) -> None:
with self.assertRaises(ValueError) as cm:
model.datatypes.from_xsd("2020-01-24+11", model.datatypes.Date)
self.assertEqual("Value is not a valid XSD date string", str(cm.exception))
with self.assertRaises(NotImplementedError):
model.datatypes.from_xsd("-2020-01-24", model.datatypes.Date)

def test_serialize_date(self) -> None:
self.assertEqual("2020-01-24", model.datatypes.xsd_repr(model.datatypes.Date(2020, 1, 24)))
Expand Down Expand Up @@ -211,6 +213,8 @@ def test_parse_datetime(self) -> None:
with self.assertRaises(ValueError) as cm:
model.datatypes.from_xsd("--2020-01-24T15:25:17-00:20", model.datatypes.DateTime)
self.assertEqual("Value is not a valid XSD datetime string", str(cm.exception))
with self.assertRaises(NotImplementedError):
model.datatypes.from_xsd("-2020-01-24T15:25:17+01:00", model.datatypes.DateTime)

def test_serialize_datetime(self) -> None:
self.assertEqual("2020-01-24T15:25:17",
Expand Down
Loading