Skip to content

Commit

Permalink
Fix techem WZ date range.
Browse files Browse the repository at this point in the history
Apparently techem reports december (or maybe january) as month 0.
  • Loading branch information
splatch committed Dec 5, 2018
1 parent 704ae42 commit e1f95e5
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ protected final LocalDateTime parseCurrentDate(byte[] buffer, int index) {
HexUtils.bytesToHex(read(buffer, index, index + 1)));
day = 1;
}
if (month <= 0) {
logger.trace("Detected invalid month number {} in byte representation: {}, changing to last month of year", month,
HexUtils.bytesToHex(read(buffer, index, index + 1)));
month = 12;
}

LocalDateTime dateTime = LocalDateTime.now().withMonth(month).withDayOfMonth(day);
return dateTime.truncatedTo(ChronoUnit.SECONDS);
Expand Down

0 comments on commit e1f95e5

Please sign in to comment.