Skip to content

Commit

Permalink
Related to issue #480 I think date should accept a real date, not jus…
Browse files Browse the repository at this point in the history
…t the minus 1900 version (#481)
  • Loading branch information
ChristianTremblay authored Feb 17, 2023
1 parent 394d6db commit 9418921
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions py25/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions py27/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions py34/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_primitive_data/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 9418921

Please sign in to comment.