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

adjustTime increments a leap year when it shouldn't. #169

Open
aord opened this issue Apr 21, 2022 · 1 comment
Open

adjustTime increments a leap year when it shouldn't. #169

aord opened this issue Apr 21, 2022 · 1 comment

Comments

@aord
Copy link

aord commented Apr 21, 2022

adjustTime increments a leap year when it shouldn't. Leap year occur on 2020 and 2024.

Adding 12 hours to the date time 28/4/2022, hour=23.
Gives 29/4/2022 hour=11.
Should be 1/5/2022 hour=11.

Tested Using Arduino UNO (clone)
Also tested with same result on a WeMos D1R1 board.

//Code copied and adjusted from TimeGPS example
#include <TimeLib.h>

void setup()
{
Serial.begin(9600);

int Year = 2022;
byte Month = 4;
byte Day = 28;
byte Hour = 23;
byte Minute = 59;
byte Second = 58;

const int offset = 12;

setTime(Hour, Minute, Second, Day, Month, Year);
adjustTime(offset * SECS_PER_HOUR);

Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}

Result: 29 4 2022
2022 is not a leap year result should be 1 5 2022

@pefferie
Copy link

pefferie commented Apr 7, 2024

4 is the month of April. There's always 30 days in April, every year

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

No branches or pull requests

2 participants