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

hour() is off when passing in a timestamp, or I'm using it wrong? #149

Open
alager opened this issue Mar 20, 2022 · 2 comments
Open

hour() is off when passing in a timestamp, or I'm using it wrong? #149

alager opened this issue Mar 20, 2022 · 2 comments

Comments

@alager
Copy link

alager commented Mar 20, 2022

Startup logs, showing correct operation for central time:
Received time: Sunday, 20-Mar-22 14:50:07.359 UTC
Time is in sync
our Timezone: America/Chicago
Timezone lookup for: America/Chicago ... (round-trip 392 ms) success.
Olson: America/Chicago
Posix: CST6CDT,M3.2.0,M11.1.0
Central Time: Sunday, 20-Mar-2022 09:50:07 CDT

Serial << "now: " << myTZ.now() << mendl;
now: 1647769859

Serial << "storedTime: " << storedTime << mendl;
storedTime: 1647769900

Serial << "timezone: " << myTZ.getTimezoneName( storedTime, LOCAL_TIME ) << mendl;
timezone: CDT

uint8_t hour = myTZ.hourFormat12();
Serial << "hour: " << hour << mendl;
hour: 9 <-- the expected value

uint8_t hourStored = myTZ.hourFormat12( storedTime, LOCAL_TIME );
Serial << "hourStored: " << hourStored << mendl;
hourStored: 2 <-- wrong value. I think it should be either 9, or 4 depending on UTC or local timezone.

uint8_t minute = myTZ.minute();
Serial << "minute: " << minute << mendl;
minute: 50

uint8_t minuteStored = myTZ.minute( storedTime, LOCAL_TIME );
Serial << "minuteStored: " << minuteStored << mendl;
minuteStored: 51

The same behavior happens with both hour() and hourFormat12()

@k5map
Copy link

k5map commented Jul 23, 2022

@alager

I'm experiencing the same problem as you with both the hour() and hourFormat12() functions. What is even more confusing is if I output hour using the dateTime() function, the hour is correct. I'm in the CDT timezone and my hour() value is +5 higher than it should be (hour() returns 9 when my local hour is 4). My timezone and DST are set correctly.

@nilton61
Copy link

I had the same problem with the day(t) function when passing a timestamp in thew t parameter. I started a new issue on this

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

3 participants