Skip to content

Wrong Leap Year Calculation #125

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

Closed
tim-scherer opened this issue Mar 4, 2022 · 6 comments · Fixed by #126
Closed

Wrong Leap Year Calculation #125

tim-scherer opened this issue Mar 4, 2022 · 6 comments · Fixed by #126
Labels
bug Something isn't working

Comments

@tim-scherer
Copy link

Subject of the issue

  • The leap year calculation yields that 2022 is a leap year; but next leap year is 2024.
  • As a result of this, epoch time calculation error is 86400 s (24 h) wrong.

Your workbench

SparkFun_u-blox_GNSS_Arduino_Library](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library Library V2.2.0

Steps to reproduce

The error is located in the calculation perfomed in

DAYS_SINCE_MONTH[((uint32_t)packetUBXNAVPVT->data.year - 1970) & 3][(uint32_t)packetUBXNAVPVT->data.month] +

and

Expected behavior

2022 is not a leap year

Actual behavior

DAYS_SINCE_MONTH[((uint32_t)packetUBXNAVPVT->data.year - 1970) & 3][(uint32_t)packetUBXNAVPVT->data.month] results as a leap year

@PaulZC
Copy link
Collaborator

PaulZC commented Mar 4, 2022

Hi @tim-scherer ,

Wow. Thanks for reporting this! That gremlin has been in there for a long time... But I guess only appeared on Tuesday...

We'll fix this in the next release.

Best wishes,
Paul

@PaulZC PaulZC added the bug Something isn't working label Mar 4, 2022
@tim-scherer
Copy link
Author

Hi @tim-scherer ,

Wow. Thanks for reporting this! That gremlin has been in there for a long time... But I guess only appeared on Tuesday...

We'll fix this in the next release.

Best wishes, Paul

This could be a fix, changing order of array (idx 0 to 3):
image

@PaulZC
Copy link
Collaborator

PaulZC commented Mar 4, 2022

The corrections are in the release_candidate branch if you would like to test them?

Please see this commit for the changes. (I updated the examples too.)

CorBer added a commit to CorBer/teensy_batdetector that referenced this issue Mar 4, 2022
@tim-scherer
Copy link
Author

Thanks a lot for the fast reply and the quick fix. Seems to work fine 👍

@papillon81
Copy link

Confirmed working. Noticed the same 24h delta today. :)

@PaulZC
Copy link
Collaborator

PaulZC commented Mar 7, 2022

Hi @tim-scherer / @papillon81 ,

Thank you both. I will release v2.2.5 in a few minutes.

Best wishes,
Paul

@PaulZC PaulZC linked a pull request Mar 7, 2022 that will close this issue
PaulZC added a commit that referenced this issue Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants