NTPClient
NTPClient copied to clipboard
AU (GMT+10)+ : Any offset over 32767 did not work - fix included
Time offset for Australia GMT +10 is 36,000 (plus 10 hours), however the datatype for offset in my library was int. The current code it is a long, and a long has a maximum value of 32,767. If you need a higher offset, ie, in Australia +10, etc, you need to modify the datatype to unsigned long, in the following locations:
NTPClient.h
line 18: unsigned long _timeOffset = 0;
lines 31-44:
NTPClient(UDP& udp, unsigned long timeOffset); NTPClient(UDP& udp, const char* poolServerName); NTPClient(UDP& udp, const char* poolServerName, unsigned long timeOffset); NTPClient(UDP& udp, const char* poolServerName, unsigned long timeOffset, int updateInterval);
line 69: void setTimeOffset(unsigned long timeOffset);
NTPClient.cpp
line 28: NTPClient::NTPClient(UDP& udp, unsigned long timeOffset) {
line 38: NTPClient::NTPClient(UDP& udp, const char* poolServerName, unsigned long timeOffset) {
line 44: NTPClient::NTPClient(UDP& udp, const char* poolServerName, unsigned long timeOffset, int updateInterval) {
line 143: void NTPClient::setTimeOffset(unsigned long timeOffset) {
Just incase you're from Australia and scratching your head like I'd been doing for an hour or so. Enjoy :)
thanks for the fix but I believe you should use "long" and not "unsigned long" as the offset can be negative.
@newymods can you please create a PR containing those changes?