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.
This commit is contained in:
Vadim Zeitlin
2017-11-30 21:44:38 +01:00
parent ef372460be
commit 0e65d91a38

View File

@@ -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));