From 64727a4a83b4770c37e9ba782da9d91830396490 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 27 Jan 2024 10:11:42 +0100 Subject: [PATCH] fix DTM type with recent dates (fixes #1172) --- ChangeLog.md | 2 ++ src/lib/ebus/datatype.cpp | 3 ++- src/lib/ebus/test/test_data.cpp | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index cd0bc7ced..41afaafcc 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,8 @@ # next (tbd) ## Bug Fixes * fix conditional messages not being sent to message definition in MQTT integration and not being used in KNX group association +* fix CSV dump of config files on command line +* fix DTM type with recent dates ## Features * add "inject" command diff --git a/src/lib/ebus/datatype.cpp b/src/lib/ebus/datatype.cpp index c301aab6b..1d6a93e14 100755 --- a/src/lib/ebus/datatype.cpp +++ b/src/lib/ebus/datatype.cpp @@ -591,7 +591,8 @@ result_t DateTimeDataType::writeSymbols(size_t offset, size_t length, istringstr if (result != RESULT_OK) { return result; // invalid time part } - if ((i == 0 && value > 24) || (i > 0 && (last == 24 && value > 0) )) { + if ((i == (m_hasDate ? 2 : 0) && value > 24) + || (i > (m_hasDate ? 2 : 0) && (last == 24 && value > 0) )) { return RESULT_ERR_OUT_OF_RANGE; // invalid time part } if (hasFlag(SPE)) { // minutes since midnight diff --git a/src/lib/ebus/test/test_data.cpp b/src/lib/ebus/test/test_data.cpp index 44f7d8e0c..02d29b683 100755 --- a/src/lib/ebus/test/test_data.cpp +++ b/src/lib/ebus/test/test_data.cpp @@ -174,7 +174,8 @@ int main() { {"x,,day", "", "10fe0700020000", "00", "Rw"}, {"x,,dtm", "01.01.2009 00:00", "10fe07000400000000", "00", ""}, {"x,,dtm", "31.12.2099 23:59", "10fe0700041f4eda02", "00", ""}, - {"x,,dtm", "16.12.2020 16:51", "10fe07000453f85f00", "00", ""}, + {"x,,dtm", "16.12.2024 16:51", "10fe07000473128000", "00", ""}, + {"x,,dtm", "24.12.2025 16:51", "10fe07000493448800", "00", ""}, {"x,,bti", "21:04:58", "10fe070003580421", "00", ""}, {"x,,bti", "00:00:00", "10fe070003000000", "00", ""}, {"x,,bti", "23:59:59", "10fe070003595923", "00", ""},