mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 795405 - All Dates in Price Database Off-By-One After 3.0 Upgrade
Also Bug 791825 - Accounting Period dates off by 1. The DST start/end dates were reversed *and* the DST offset had the wrong sign in Windows, resulting in the effective timezone always being one to the west off (i.e. PDT was -9 and PST was -8).
This commit is contained in:
parent
83e993fb80
commit
9c4469d039
@ -150,9 +150,15 @@ zone_from_regtzi (const RegTZI& regtzi, time_zone_names names)
|
|||||||
{
|
{
|
||||||
using ndate = boost::gregorian::nth_day_of_the_week_in_month;
|
using ndate = boost::gregorian::nth_day_of_the_week_in_month;
|
||||||
using nth_day_rule = boost::local_time::nth_day_of_the_week_in_month_dst_rule;
|
using nth_day_rule = boost::local_time::nth_day_of_the_week_in_month_dst_rule;
|
||||||
|
/* Note that Windows runs its biases backwards from POSIX and
|
||||||
|
* boost::date_time: It's the value added to the local time to get
|
||||||
|
* GMT rather than the value added to GMT to get local time; for
|
||||||
|
* the same reason the DaylightBias is negative as one generally
|
||||||
|
* adds an hour less to the local time to get GMT. Biases are in
|
||||||
|
* minutes.
|
||||||
|
*/
|
||||||
duration std_off (0, regtzi.StandardBias - regtzi.Bias, 0);
|
duration std_off (0, regtzi.StandardBias - regtzi.Bias, 0);
|
||||||
duration dlt_off (0, regtzi.DaylightBias, 0);
|
duration dlt_off (0, -regtzi.DaylightBias, 0);
|
||||||
duration start_time (regtzi.StandardDate.wHour, regtzi.StandardDate.wMinute,
|
duration start_time (regtzi.StandardDate.wHour, regtzi.StandardDate.wMinute,
|
||||||
regtzi.StandardDate.wSecond);
|
regtzi.StandardDate.wSecond);
|
||||||
duration end_time (regtzi.DaylightDate.wHour, regtzi.DaylightDate.wMinute,
|
duration end_time (regtzi.DaylightDate.wHour, regtzi.DaylightDate.wMinute,
|
||||||
@ -165,10 +171,10 @@ zone_from_regtzi (const RegTZI& regtzi, time_zone_names names)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ndate start (std_week_num, regtzi.StandardDate.wDayOfWeek,
|
ndate start (dlt_week_num, regtzi.DaylightDate.wDayOfWeek,
|
||||||
regtzi.StandardDate.wMonth);
|
regtzi.DaylightDate.wMonth);
|
||||||
ndate end(dlt_week_num, regtzi.DaylightDate.wDayOfWeek,
|
ndate end(std_week_num, regtzi.StandardDate.wDayOfWeek,
|
||||||
regtzi.DaylightDate.wMonth);
|
regtzi.StandardDate.wMonth);
|
||||||
dates.reset(new nth_day_rule (start, end));
|
dates.reset(new nth_day_rule (start, end));
|
||||||
}
|
}
|
||||||
catch (boost::gregorian::bad_month& err)
|
catch (boost::gregorian::bad_month& err)
|
||||||
|
@ -46,17 +46,21 @@ TEST(gnc_timezone_constructors, test_pacific_time_constructor)
|
|||||||
TimeZoneProvider tzp (timezone);
|
TimeZoneProvider tzp (timezone);
|
||||||
EXPECT_NO_THROW (tzp.get(2012));
|
EXPECT_NO_THROW (tzp.get(2012));
|
||||||
TZ_Ptr tz = tzp.get (2012);
|
TZ_Ptr tz = tzp.get (2012);
|
||||||
|
|
||||||
EXPECT_FALSE(tz->std_zone_abbrev().empty());
|
EXPECT_FALSE(tz->std_zone_abbrev().empty());
|
||||||
#if PLATFORM(WINDOWS)
|
#if PLATFORM(WINDOWS)
|
||||||
EXPECT_TRUE(tz->std_zone_abbrev() == timezone);
|
EXPECT_TRUE(tz->std_zone_abbrev() == timezone);
|
||||||
|
EXPECT_TRUE(tz->dst_zone_abbrev() == "Pacific Daylight Time");
|
||||||
#else
|
#else
|
||||||
EXPECT_TRUE(tz->std_zone_abbrev() == "PST");
|
EXPECT_TRUE(tz->std_zone_abbrev() == "PST");
|
||||||
EXPECT_TRUE(tz->dst_zone_abbrev() == "PDT");
|
EXPECT_TRUE(tz->dst_zone_abbrev() == "PDT");
|
||||||
#endif
|
#endif
|
||||||
EXPECT_EQ(-8, tz->base_utc_offset().hours());
|
EXPECT_EQ(-8, tz->base_utc_offset().hours());
|
||||||
|
auto dst_offset = tz->base_utc_offset() + tz->dst_offset();
|
||||||
|
EXPECT_EQ(-7, dst_offset.hours());
|
||||||
EXPECT_EQ(12, tz->dst_local_start_time (2017).date().day());
|
EXPECT_EQ(12, tz->dst_local_start_time (2017).date().day());
|
||||||
|
EXPECT_EQ(3, tz->dst_local_start_time (2017).date().month());
|
||||||
|
EXPECT_EQ(5, tz->dst_local_end_time (2017).date().day());
|
||||||
|
EXPECT_EQ(11, tz->dst_local_end_time (2017).date().month());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !PLATFORM(WINDOWS)
|
#if !PLATFORM(WINDOWS)
|
||||||
@ -284,8 +288,13 @@ TEST(gnc_timezone_constructors, test_IANA_Minsk_tz)
|
|||||||
|
|
||||||
TEST(gnc_timezone_constructors, test_bogus_time_constructor)
|
TEST(gnc_timezone_constructors, test_bogus_time_constructor)
|
||||||
{
|
{
|
||||||
|
#if PLATFORM(WINDOWS)
|
||||||
|
EXPECT_THROW(TimeZoneProvider tzp ("New York Standard Time"),
|
||||||
|
std::invalid_argument);
|
||||||
|
#else
|
||||||
TimeZoneProvider tzp ("New York Standard Time");
|
TimeZoneProvider tzp ("New York Standard Time");
|
||||||
TimeZoneProvider machine ("");
|
TimeZoneProvider machine ("");
|
||||||
EXPECT_EQ(machine.get(2006)->std_zone_abbrev(),
|
EXPECT_EQ(machine.get(2006)->std_zone_abbrev(),
|
||||||
tzp.get(2006)->std_zone_abbrev());
|
tzp.get(2006)->std_zone_abbrev());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,6 @@ gnucash/report/report-system/html-acct-table.scm
|
|||||||
gnucash/report/report-system/html-barchart.scm
|
gnucash/report/report-system/html-barchart.scm
|
||||||
gnucash/report/report-system/html-document.scm
|
gnucash/report/report-system/html-document.scm
|
||||||
gnucash/report/report-system/html-fonts.scm
|
gnucash/report/report-system/html-fonts.scm
|
||||||
gnucash/report/report-system/html-jqplot.scm
|
|
||||||
gnucash/report/report-system/html-linechart.scm
|
gnucash/report/report-system/html-linechart.scm
|
||||||
gnucash/report/report-system/html-piechart.scm
|
gnucash/report/report-system/html-piechart.scm
|
||||||
gnucash/report/report-system/html-scatter.scm
|
gnucash/report/report-system/html-scatter.scm
|
||||||
|
Loading…
Reference in New Issue
Block a user