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

NTPClient now returns date, year, month and day. #161

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

barsrb
Copy link

@barsrb barsrb commented Dec 24, 2021

To get day of week now use getDayOfWeek()

To get day of week now use getDayOfWeek()
@CLAassistant
Copy link

CLAassistant commented Dec 24, 2021

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

Memory usage change @ 1fab9d7

Board flash % RAM for global variables %
esp8266:esp8266:huzzah 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/Advanced
flash
% examples/Advanced
RAM for global variables
% examples/Basic
flash
% examples/Basic
RAM for global variables
% examples/IsTimeSet
flash
% examples/IsTimeSet
RAM for global variables
%
esp8266:esp8266:huzzah 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/Advanced<br>flash,%,examples/Advanced<br>RAM for global variables,%,examples/Basic<br>flash,%,examples/Basic<br>RAM for global variables,%,examples/IsTimeSet<br>flash,%,examples/IsTimeSet<br>RAM for global variables,%
esp8266:esp8266:huzzah,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0

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.
int fullYears = days / 365;
int overDays = days % 365;

int leapYears = (fullYears - 2) / 4;
Copy link

@poveden poveden Mar 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) 1973 (1970 + 3)

Fortunately, it can be easily fixed:

Suggested change
int leapYears = (fullYears - 2) / 4;
int leapYears = (fullYears + 1) / 4;

@per1234
Copy link
Contributor

per1234 commented Jan 12, 2023

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jan 12, 2023
@thaianhtaivn
Copy link

Hello @per1234 ,
Can we merge it to master? Cause we usually use these functions for getting dates info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the functionallity to get the date getFormattedTime does not give date+time string
5 participants