NTPClient icon indicating copy to clipboard operation
NTPClient copied to clipboard

AU (GMT+10)+ : Any offset over 32767 did not work - fix included

Open ghost opened this issue 6 years ago • 2 comments
trafficstars

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 :)

ghost avatar Jul 08 '19 22:07 ghost

thanks for the fix but I believe you should use "long" and not "unsigned long" as the offset can be negative.

jacob-jarick avatar Aug 29 '19 16:08 jacob-jarick

@newymods can you please create a PR containing those changes?

aentinger avatar Sep 19 '19 04:09 aentinger