Skip to content

Commit

Permalink
Merge pull request #121 from zivillian/invalid_date
Browse files Browse the repository at this point in the history
handle invalid date graceful
  • Loading branch information
zivillian authored Aug 25, 2024
2 parents c55bdc2 + 3198a71 commit 360dca5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ism7mqtt/ISM7/Xml/BM2DateConverterTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ protected override void AddTelegram(byte low, byte high)
var day = value & 0b1_1111;
var month = (value >> 5) & 0xf;
var year = value >> 9;
if (month > 11)
{
Console.Error.WriteLine($"received invalid date for {nameof(BM2DateConverterTemplate)}({TelegramNr}). Make sure you have a correct time set on your BM2");
return;
}
_value = new DateTime(2000 + year, month + 1, day + 1);
}

Expand Down

0 comments on commit 360dca5

Please sign in to comment.