Fix GncDateTime tests on Windows.

pull/2125/head
John Ralls 9 months ago
parent 6666027a9b
commit dcb7a8c242

@ -585,7 +585,7 @@ std::string
GncDateTimeImpl::format_zulu(const char* format) const
{
#ifdef __MINGW32__
auto tz = m_time.zone();
auto tz = utc_zone;
auto tm = static_cast<struct tm>(*this);
auto sformat = win_format_tz_abbrev(format, tz, tm.tm_isdst);
sformat = win_format_tz_name(sformat, tz, tm.tm_isdst);

@ -451,7 +451,17 @@ TEST(gnc_datetime_constructors, test_DST_start_transition_time)
_reset_tzp();
_set_tzp(tzp_can);
for (auto hours = 0; hours < 23; ++hours)
{
#ifdef __MINGW32__
/* Windows thinks 02:59:00 is still DST; of course on the transition
* day there is no 02:59, local time goes from 01:59:59 to 03:00:00 so
* it's an artifact anyway.
*/
if (hours == 2)
continue;
#endif
EXPECT_TRUE(test_offset(1601737140, hours, 36000, 39600, "Canberra"));
}
_reset_tzp();
}
@ -474,13 +484,13 @@ TEST(gnc_datetime_constructors, test_DST_end_transition_time)
_reset_tzp();
}
#ifndef __MINGW32__
/* MSWindows doesn't provide historical timezone information. Brazil
* doesn't use DST since 2019 so these tests don't work.
*/
TEST(gnc_datetime_constructors, test_create_in_transition)
{
#ifdef __MINGW32__
TimeZoneProvider tzp_br{"E. South America Standard Time"};
#else
TimeZoneProvider tzp_br("America/Sao_Paulo");
#endif
_set_tzp(tzp_br);
/* Test Daylight Savings start: When Sao Paolo had daylight
* savings time it ended at 23:59:59 and the next second was
@ -519,6 +529,7 @@ TEST(gnc_datetime_constructors, test_create_in_transition)
EXPECT_EQ(gncdt3.format_zulu("%Y-%m-%d %H:%M:%S %Z"), "2019-11-01 03:00:00 UTC");
EXPECT_EQ(gncdt3.format("%Y-%m-%d %H:%M:%S %Z"), "2019-11-01 00:00:00 -03");
}
#endif
TEST(gnc_datetime_constructors, test_gncdate_neutral_constructor)
{

Loading…
Cancel
Save