diff --git a/py25/bacpypes/primitivedata.py b/py25/bacpypes/primitivedata.py index a22e9a45..ce7fc1f0 100755 --- a/py25/bacpypes/primitivedata.py +++ b/py25/bacpypes/primitivedata.py @@ -1294,6 +1294,7 @@ class Date(Atomic): _app_tag = Tag.dateAppTag def __init__(self, arg=None, year=255, month=255, day=255, day_of_week=255): + year = year - 1900 if year >= 1900 else year self.value = (year, month, day, day_of_week) if arg is None: diff --git a/py27/bacpypes/primitivedata.py b/py27/bacpypes/primitivedata.py index a659a2ce..893c5b56 100755 --- a/py27/bacpypes/primitivedata.py +++ b/py27/bacpypes/primitivedata.py @@ -1340,6 +1340,7 @@ class Date(Atomic): _app_tag = Tag.dateAppTag def __init__(self, arg=None, year=255, month=255, day=255, day_of_week=255): + year = year - 1900 if year >= 1900 else year self.value = (year, month, day, day_of_week) if arg is None: diff --git a/py34/bacpypes/primitivedata.py b/py34/bacpypes/primitivedata.py index bf94bca2..57f842e2 100755 --- a/py34/bacpypes/primitivedata.py +++ b/py34/bacpypes/primitivedata.py @@ -1322,6 +1322,7 @@ class Date(Atomic): _app_tag = Tag.dateAppTag def __init__(self, arg=None, year=255, month=255, day=255, day_of_week=255): + year = year - 1900 if year >= 1900 else year self.value = (year, month, day, day_of_week) if arg is None: diff --git a/tests/test_primitive_data/test_date.py b/tests/test_primitive_data/test_date.py index 32cba6e9..c5fba208 100644 --- a/tests/test_primitive_data/test_date.py +++ b/tests/test_primitive_data/test_date.py @@ -181,3 +181,10 @@ def test_Wrong(self): for each in self.notEnoughPreciseOrWrong: Date(each[0]) + def test_date_args(self): + t = Tag() + date = Date(year=2023, month=2, day=10) + date1 = Date(year=123, month=2, day=10) + assert date == date1 + date.encode(t) +