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

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

Open
ghost opened this issue Jul 8, 2019 · 2 comments · May be fixed by #181
Open

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

ghost opened this issue Jul 8, 2019 · 2 comments · May be fixed by #181
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@ghost
Copy link

ghost commented Jul 8, 2019

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

@jacob-jarick
Copy link

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

@aentinger
Copy link
Contributor

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

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Mar 28, 2022
@per1234 per1234 linked a pull request Oct 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants