|
|
|
|
@ -518,15 +518,34 @@ TEST(gnc_datetime_functions, test_date)
|
|
|
|
|
EXPECT_EQ(ymd.day - (12 + atime.offset() / 3600) / 24, 13);
|
|
|
|
|
}
|
|
|
|
|
/* This test works only in the America/LosAngeles time zone and
|
|
|
|
|
* there's no way at present to make it more flexible.
|
|
|
|
|
TEST(gnc_datetime_functions, test_timezone_offset)
|
|
|
|
|
* there's no straightforward wat to make it more flexible. It ensures
|
|
|
|
|
* that DST in that timezone transitions correctly for each day of the
|
|
|
|
|
* week in which March begines.
|
|
|
|
|
|
|
|
|
|
TEST(gnc_datetime_functions, test_timezone_offset)
|
|
|
|
|
{
|
|
|
|
|
struct Timepair
|
|
|
|
|
{
|
|
|
|
|
time64 before;
|
|
|
|
|
time64 after;
|
|
|
|
|
};
|
|
|
|
|
std::array<Timepair, 7> years{
|
|
|
|
|
Timepair{1615633140, 1615719540}, //2021, Monday
|
|
|
|
|
Timepair{1457780340, 1457866740}, //2016, Tuesday
|
|
|
|
|
Timepair{1489229940, 1489316340}, //2017, Wednesday
|
|
|
|
|
Timepair{1520679540, 1520765940}, //2018, Thursday
|
|
|
|
|
Timepair{1552129140, 1552215540}, //2019, Friday
|
|
|
|
|
Timepair{1741431540, 1741517940}, //2025, Saturday
|
|
|
|
|
Timepair{1583578740, 1583665140} //2020, Sunday
|
|
|
|
|
};
|
|
|
|
|
for (auto year : years)
|
|
|
|
|
{
|
|
|
|
|
GncDateTime before{year.before};
|
|
|
|
|
GncDateTime after{year.after};
|
|
|
|
|
// std::cerr << before.format_iso8601() << std::endl;
|
|
|
|
|
EXPECT_EQ(-28800, before.offset());
|
|
|
|
|
EXPECT_EQ(-25200, after.offset());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GncDateTime gncdt1(1488797940); //6 Mar 2017
|
|
|
|
|
EXPECT_EQ(-28800, gncdt1.offset());
|
|
|
|
|
GncDateTime gncdt2(1489661940); //16 Mar 2017 10:59 Z
|
|
|
|
|
EXPECT_EQ(-25200, gncdt2.offset());
|
|
|
|
|
GncDateTime gncdt3(1490525940); //26 Mar 2017
|
|
|
|
|
EXPECT_EQ(-25200, gncdt3.offset());
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|