NTPClient now returns date, year, month and day.#161
Open
barsrb wants to merge 2 commits intoarduino-libraries:masterfrom
Open
NTPClient now returns date, year, month and day.#161barsrb wants to merge 2 commits intoarduino-libraries:masterfrom
barsrb wants to merge 2 commits intoarduino-libraries:masterfrom
Conversation
To get day of week now use getDayOfWeek()
|
Memory usage change @ 1fab9d7
Click for full report table
Click for full report CSV |
The identifier `leapYears` was being detected by the spell checker tool as a misspelling of "leap years". The false positive is resolved by adding `leapyears` to the ignore list in the `.codespellrc` configuration file.
poveden
reviewed
Mar 12, 2022
| int fullYears = days / 365; | ||
| int overDays = days % 365; | ||
|
|
||
| int leapYears = (fullYears - 2) / 4; |
There was a problem hiding this comment.
getYear() fails for all days that match December 31st, except for the year 1970 and those where the next year is a leap one (brute-tested using Excel):
| Code | 1970/12/31 | 1971/12/31 | 1972/12/31 |
|---|---|---|---|
days |
364 | 729 (365+364) | 1095 (365+365+365) |
fullYears = days / 365 |
0 (364 / 365) | 1 (729 / 365) | 3 (1095 / 365) |
overDays = days % 365 |
364 (364 % 365) | 364 (729 % 365) | 0 (1095 % 365) |
leapYears = (fullYears - 2) / 4 |
0 ((0 − 2) / 4) | 0 ((1 − 2) / 4) | 0 ((3 − 2) / 4) |
if (leapYears > overDays) fullYears-- |
0 (No change) | 1 (No change) | 3 (No change) |
return 1970 + fullYears |
1970 (1970 + 0) | 1971 (1970 + 1) |
Fortunately, it can be easily fixed:
Suggested change
| int leapYears = (fullYears - 2) / 4; | |
| int leapYears = (fullYears + 1) / 4; |
Contributor
|
Hello @per1234 , |
This was
linked to
issues
Jun 23, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To get day of week now use getDayOfWeek()