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

Incorrect DST handling for southern hemisphere? #16

Open
mdarnold1 opened this issue Nov 19, 2022 · 5 comments
Open

Incorrect DST handling for southern hemisphere? #16

mdarnold1 opened this issue Nov 19, 2022 · 5 comments

Comments

@mdarnold1
Copy link

DST for southern hemisphere timezones does not seem to work correctly.
NTP::summerTime() assumes that utcDST<utcSTD, and NTP::beginDST() assumes both utcDST & utcSTD apply to current->tm_year. Then it follows that NTP::summerTime() always returns false for the southern hemisphere.

@sstaub
Copy link
Owner

sstaub commented Nov 20, 2022

Can you give me an example, maybe you must use a "-" for DST.

@sstaub
Copy link
Owner

sstaub commented Dec 10, 2022

Does it work?

@mtongnz
Copy link

mtongnz commented Oct 13, 2023

I also have this issue using NZ timezone (UTC + 12).

My workaround is to put STD in the DST and DST in the STD:

uint8_t utcOff = 12;
timeClient.ruleSTD("NZDT", Last, Sun, Sep, 2, (utcOff+1) * 60);
timeClient.ruleDST("NZST", First, Sun, Apr, 3, utcOff * 60);

Annoying but works

@mtongnz
Copy link

mtongnz commented Oct 13, 2023

Looking at NTP.cpp, I think it's in the NTP::summerTime() method (line 274).

This is untested but might fix it ??

bool NTP::summerTime() {
	if ((utcCurrent < 0) {
		if ((utcCurrent > utcDST) && (utcCurrent <= utcSTD)) {
			return true;
		}
	} else if ((utcCurrent < utcDST) && (utcCurrent >= utcSTD)) {
		return true;
	}
	return false;
}

@ggatenby
Copy link

ggatenby commented Oct 6, 2024

I also have this issue using NZ timezone (UTC + 12).

My workaround is to put STD in the DST and DST in the STD:

uint8_t utcOff = 12;
timeClient.ruleSTD("NZDT", Last, Sun, Sep, 2, (utcOff+1) * 60);
timeClient.ruleDST("NZST", First, Sun, Apr, 3, utcOff * 60);

Annoying but works

Same workaround appears to work for me as well - will be able to confirm 100% at end of DST in April 2025. I'm in Australia - also southern hemisphere but UTC +10/+11 DST

I agree with @mdarnold1 that the logic is flawed in that in the southern hemisphere DST commences late in one calendar year and ends early in the next, whereas in the northern hemisphere it commences and ends in the same year so as both @mdarnold1
and @mtongnz point out the problem would appear to lie within the logic surrounding NTP::summerTime() method (line 274).

This can be fairly easily proven by changing ntp.ruleSTD("AEST", Last, Sun, Mar, 2, 600) to ntp.ruleSTD("AEST", Last, Sun, Nov, 2, 600) which in effect brings DST end into the same calendar year as DST start which in turn causes the correct offset to be applied

Ultimately though I can't see an easy fix without adding an additional configuration parameter

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

4 participants