1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00

Related to issue #480 I think date should accept a real date, not just the minus 1900 version (#481)

This commit is contained in:
Christian Tremblay 2023-02-16 23:23:07 -05:00 committed by GitHub
parent 394d6dbcec
commit 941892134a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 0 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -181,3 +181,10 @@ class TestDate(unittest.TestCase):
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)