Fix wrong date of beginning of epoch.

This commit is contained in:
John Ralls
2022-04-07 09:34:59 -07:00
parent 7147e8a6e5
commit 7b1c0509f7
2 changed files with 18 additions and 4 deletions

View File

@@ -655,7 +655,7 @@ gnc_date_edit_class_init (GNCDateEditClass *klass)
PROP_TIME,
g_param_spec_int64("time",
"Date/time (seconds)",
"Date/time represented in seconds since Januari 31st, 1970",
"Date/time represented in seconds since midnight UTC, 1 January 1970",
G_MININT64,
G_MAXINT64,
0,

View File

@@ -93,13 +93,27 @@ struct _GncABImExContextImport
GData *tmp_job_list;
};
static inline is_leap_year (int year)
{
return (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0 ));
}
static inline time64
gnc_gwen_date_to_time64 (const GNC_GWEN_DATE* date)
{
#if AQBANKING_VERSION_INT >= 59900
return gnc_dmy2time64_neutral(GWEN_Date_GetDay(date),
GWEN_Date_GetMonth(date),
GWEN_Date_GetYear(date));
int day = GWEN_Date_GetDay(date);
int month = GWEN_Date_GetMonth(date);
int year = GWEN_Date_GetYear(date);
/* Some banks use nominal 30-day months and set the value date as
* the day after the posted date. In February this can appear to
* be an invalid date because February has fewer than 30 days. If
* that's the case then back up a day to get a real date for
* posting.
*/
if (month == 2 && day <= 30 && day > is_leap_year(year) ? 29 : 28)
--day;
return gnc_dmy2time64_neutral(day, month, year);
#else
int month, day, year;
GWEN_Time_GetBrokenDownDate(date, &day, &month, &year);