Skip to content

Commit

Permalink
Bug 772382 - Date off-by-one after DST change
Browse files Browse the repository at this point in the history
The time needs to be 10:59, not 11:00: 13 hours after 11:00 is 24:00,
which is really 00:00 the next day.
  • Loading branch information
jralls committed Oct 9, 2016
1 parent 6e132d8 commit b00694f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/libqof/qof/gnc-date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,16 +1237,16 @@ gnc_dmy2timespec_neutral (int day, int month, int year)
date.tm_year = year - 1900;
date.tm_mon = month - 1;
date.tm_mday = day;
date.tm_hour = 11;
date.tm_min = 0;
date.tm_hour = 10;
date.tm_min = 59;
date.tm_sec = 0;

GncDateTime gncdt(date);
auto offset = gncdt.offset() / 3600;
if (offset < -11)
date.tm_hour = -offset;
if (offset > 13)
date.tm_hour = 24 - offset;
date.tm_hour = 23 - offset;

return {gnc_timegm(&date), 0};
}
Expand Down
8 changes: 4 additions & 4 deletions src/libqof/qof/test/test-gnc-date.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ setup_begin(FixtureB *f, gconstpointer pData)
static void
setup_neutral(FixtureB *f, gconstpointer pData)
{
f->test[0] = (TimeMap){1999, 7, 21, INT64_C(932554800)};
f->test[1] = (TimeMap){1918, 3, 31, INT64_C(-1633266000)};
f->test[2] = (TimeMap){1918, 4, 1, INT64_C(-1633179600)};
f->test[3] = (TimeMap){2057, 11, 20, INT64_C(2773479600)};
f->test[0] = (TimeMap){1999, 7, 21, INT64_C(932554740)};
f->test[1] = (TimeMap){1918, 3, 31, INT64_C(-1633266060)};
f->test[2] = (TimeMap){1918, 4, 1, INT64_C(-1633179660)};
f->test[3] = (TimeMap){2057, 11, 20, INT64_C(2773479540)};
}

static void
Expand Down

0 comments on commit b00694f

Please sign in to comment.