Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By RogerF
#75111 I realize that this is a very basic question but I have not found the answer so far. I'm experimenting with the time.h library and wondering where I can find simple clear documentation for the code below, including specifically a description of what these functions and parameters do:

configTime(timezone * 3600, dst * 0, "pool.ntp.org", "time.nist.gov");
time_t now = time(nullptr);
Serial.println(ctime(&now));

Thanks for any suggestions.
User avatar
By rudy
#75115 https://github.com/esp8266/Arduino/blob ... time.c#L58

void configTime(int timezone, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)

I'm at work, if I was at home I would have more to include. I have been looking on and off into "time" for the last few weeks. It has been confusing but I think I mainly have it all now.

https://github.com/esp8266/Arduino/blob ... TZ-DST.ino this was what I was trying to understand. I am trying to integrate the DS3231 real time clock using the existing functions. Not using external Time libraries.
User avatar
By schufti
#75122 have a look at this post viewtopic.php?p=75120#p75120
If you want to use a rtc-chip you don't use configTime(), just initialize the systemclock with the time from your rtc like in part of "back in time" (get unix timestamp via newlibc functions), systemclock is started during boot-up.
User avatar
By RogerF
#75141 Thanks to Rudy and schufti for your responses. Additional examples are always helpful. My problem is more basic: I have some code that I copied from elsewhere that works, but I'm not sure what it's doing and I'm not very experienced with C++.

I did discover that the Arduino Time Library describes now() and time_t, but I'm still not sure where configTime() comes from. And I'm still not sure why nullptr and &now are used in my original examples, which were:

configTime(timezone * 3600, dst * 0, "pool.ntp.org", "time.nist.gov");
time_t now = time(nullptr);
Serial.println(ctime(&now));

If there is some more basic forum where these questions should be asked, I would be glad to know what it is. Thanks again.


.