From 0e65d91a38e3a77f0c040a18006835627cd88c2d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Nov 2017 21:44:38 +0100 Subject: [PATCH] Correctly detect DST in UK during 1969-1971 BST-only period Take into account that from 1968-10-27 and until 1971-10-31 UK used BST time instead of GMT, i.e. that DST was permanently on. This fixes unit test failures in BST time zone for the dates around the Unix epoch of 1970-01-01. See #15370. --- src/common/datetime.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index da0a512299..96c8c12a56 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -2081,10 +2081,28 @@ int wxDateTime::IsDST(wxDateTime::Country country) const { int year = GetYear(); - if ( !IsDSTApplicable(year, country) ) + country = GetCountry(); + switch ( country ) { - // no DST time in this year in this country - return -1; + case UK: + // There is a special, but important, case of UK which was + // permanently on BST, i.e. using DST, during this period. It + // is important because it covers Unix epoch and without + // accounting for the DST during it, various tests done around + // the epoch time would fail in BST time zone (only!). + if ( IsEarlierThan(wxDateTime(31, Oct, 1971)) && + IsLaterThan(wxDateTime(27, Oct, 1968)) ) + { + return true; + } + wxFALLTHROUGH; + + default: + if ( !IsDSTApplicable(year, country) ) + { + // no DST time in this year in this country + return -1; + } } return IsBetween(GetBeginDST(year, country), GetEndDST(year, country));