Explicitly disambiguate local time zone from UTC

Don't rely on time zone offset to check whether it is local as this
doesn't, and can't, work for the local time zone in Great Britain which
uses the same offset as UTC, but does use DST, unlike the latter.

Add a unit test (albeit disabled by default) checking that the code that
previously didn't work correctly in BST does work now (run the tests
using "TZ=Europe/London ./test wxDateTime-BST-bugs" under Unix to test).

Closes #14317, #17220.

See #10445.
This commit is contained in:
Vadim Zeitlin
2017-11-29 22:58:06 +01:00
parent f13b7c6a55
commit 543c522cb8
4 changed files with 48 additions and 6 deletions

View File

@@ -254,6 +254,17 @@ public:
/// Create a time zone with the given offset in seconds.
static TimeZone Make(long offset);
/**
Return true if this is the local time zone.
This method can be useful for distinguishing between UTC time zone
and local time zone in Great Britain, which use the same offset as
UTC (i.e. 0), but do use DST.
@since 3.1.1
*/
bool IsLocal() const;
/// Return the offset of this time zone from UTC, in seconds.
long GetOffset() const;
};