Skip to content

Conversation

@manuelaznar
Copy link

Description

This Pull Request fixes an issue where the DayOfWeek value was lost during the conversion from GXDateTime to GXDate.

In the previous implementation, the GXDate(GXDateTime) constructor did not copy the DayOfWeek field, and GXCommon.setDate was recalculating it from the calendar even if a specific value was already provided in the GXDateTime object.

Changes

  1. GXDate.java: Added this.setDayOfWeek(forvalue.getDayOfWeek()); to the constructor that accepts a GXDateTime object.
  2. GXCommon.java: Updated setDate logic to prioritize the DayOfWeek value stored in the GXDateTime object. If it's not set (0), it falls back to the calendar calculation, ensuring consistency with how setDateTime behaves.

Why is this important?

In DLMS/COSEM, the Day of Week byte is mandatory for the 5-byte date structure. Without this fix, manual overrides or specific day assignments in GXDateTime were ignored when the object was treated as a GXDate during serialization, leading to potential mismatches with the meter's expected values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant