Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Days in leap year are not correctly retrieved from the controller #203

Closed
Brano5 opened this issue Aug 7, 2023 · 3 comments · Fixed by #368
Closed

[BUG] Days in leap year are not correctly retrieved from the controller #203

Brano5 opened this issue Aug 7, 2023 · 3 comments · Fixed by #368
Assignees
Labels
bug Something isn't working known-issue question Further information is requested s7-webapi
Milestone

Comments

@Brano5
Copy link
Collaborator

Brano5 commented Aug 7, 2023

When I try to set a date that is 29.2 or later in a leap year. In PLC it is set correctly, but in Onliner it has different values. As shown in image:

Snímka obrazovky 2023-08-07 091859
@Brano5 Brano5 added bug Something isn't working question Further information is requested known-issue labels Aug 7, 2023
@PTKu PTKu added the s7-webapi label Aug 9, 2023
@PTKu PTKu added this to the v0.2 milestone Aug 16, 2023
@PTKu PTKu self-assigned this Aug 16, 2023
@Specter-13
Copy link
Contributor

/cib

@IX-BOT
Copy link
Contributor

IX-BOT commented Sep 22, 2023

Branch 203-_BUG_Leap_year_has_strange_behavior created!

@Specter-13
Copy link
Contributor

Specter-13 commented Sep 25, 2023

Culprit

This bug occurs, when date value (DATE, LDATE, DATETIME, LDATETIME) from PLC is read over WebApi.
It happens:

  1. when is a leap year and date is after 29th february
    e.g. : 05.20.2000 ( WebApi will return 05.21.2000 )

  2. when is a next year after leap year before 28th february
    e.g.: 02.13.2001 (WebApi will return 02.14.2001)

  3. 27th february and 28th february a year after leap year read over webapi return same value

image

The culprit is GetFromBinary(long value) method in corresponding WebApi primitive files (WebApiDate.cs, WebApiLDate.cs, WebApiDatetime.cs, WebapiILDatetime.cs). The returned binary value from WebApi is not correct and these inconsistencies happen.

Reproduced in this branch 203-_BUG_Leap_year_has_strange_behavior in AX_Sharp.cs test file.

Plc values are defined in ax-test-project in program.st file:

image

Temporary fix

Temporary not-fully fix was introduced, where date is checked for a leap year a corresponding corrections are done:
This fix is not working for dates 27th february and 28th february (a year after leap year, eg 2001), as they return same value.

image

@PTKu

@PTKu PTKu modified the milestones: v0.15, v0.17, v0.18 Nov 22, 2023
@PTKu PTKu modified the milestones: v0.18, v0.22.0 Jan 21, 2025
@PTKu PTKu changed the title [BUG] Leap year has strange behavior [BUG] Leap year has strange behavior__ Jan 24, 2025
@PTKu PTKu changed the title [BUG] Leap year has strange behavior__ [BUG] Days in leap year are not correctly retrieved from the controller Jan 24, 2025
PTKu added a commit that referenced this issue Jan 24, 2025
@PTKu PTKu closed this as completed in #368 Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working known-issue question Further information is requested s7-webapi
Projects
None yet
4 participants