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

compileTime() wrong TZ #26

Closed
mike-s123 opened this issue Feb 1, 2019 · 5 comments
Closed

compileTime() wrong TZ #26

mike-s123 opened this issue Feb 1, 2019 · 5 comments

Comments

@mike-s123
Copy link
Contributor

Compiled a sketch at 6:23 PM EST.

In the sketch, with myTZ.setPosix("EST5EDT,M3.2.0,M11.1.0"),

dateTime(compileTime(),RFC850) produces "Friday, 01-Feb-2019 23:17:55 EST"

So, it seems to be showing the time in UTC, but labeling it as EST.

@ropg
Copy link
Owner

ropg commented Feb 2, 2019

Compile time is not stored with a timezone, so ezTime cannot know. So it assumes that compileTime is UTC. Can you try MyTz.setTime(compileTime()) and then just dateTime()?

@mike-s123
Copy link
Contributor Author

mike-s123 commented Feb 2, 2019

Thanks, that works to properly display the compile time, but it's not clear how to get back to the correct time after...

Timezone myTz;
myTz.setPosix("EST5EDT,M3.2.0,M11.1.0");
 { time_t timeHold;
   unsigned long milliHold;
   Timezone UTC;
   if ( queryNTP("192.168.168.1", timeHold, milliHold)) { 
     myTz.setTime(compileTime());
   } 
   response_message = dateTime(RFC850);
   UTC.setTime(timeHold);
 }

so far, so good. But since setTime only takes full seconds, each pass could cause up to a 1 second error when restoring the proper time.

I settled on just using
dateTime(compileTime(),"l, d-M-y G:i:s ~U~T~C"));
, which I think is still going to bounce around by an hour with summertime changes.

@ropg
Copy link
Owner

ropg commented Feb 6, 2019

I have no idea what you're trying to do there. If you have an NTP server, then why on earth would you use compileTime? compileTime, in my view, is not really useful for more than impressing your friends if you have no internet and want to show an Arduino displaying something like the proper time, it is nothing more than the static time the binary was compiled, after all.

@mike-s123
Copy link
Contributor Author

I'm using this on an ESP8266 based project. On an informational web page, we show info about the state, sketch size, free heap, code version, etc. I added compileTime to that, so I'm using it for what it actually is (or should be) instead of DATE and TIME, where I have no control over format.

@ropg
Copy link
Owner

ropg commented Mar 26, 2019

Ah, in that case, try dateTime(compileTime() - ( yourTZ.getOffset() * 60 ) ), that might correct compileTime expressed in the time of a timezone.

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