|
29 | 29 | #include <stdint.h> |
30 | 30 | #include <stdlib.h> |
31 | 31 | #include "gnc-date.h" |
| 32 | +#include "gnc-datetime.hpp" |
32 | 33 | #include "gnc-pricedb-p.h" |
33 | 34 | #include <qofinstance-p.h> |
34 | 35 |
|
@@ -1590,23 +1591,15 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list, |
1590 | 1591 | g_slist_length (data.list), datebuff); |
1591 | 1592 |
|
1592 | 1593 | // Check for a valid fiscal end of year date |
1593 | | - if (fiscal_end_date == nullptr) |
| 1594 | + if (fiscal_end_date == nullptr || !g_date_valid (fiscal_end_date)) |
1594 | 1595 | { |
1595 | | - GDate today; |
1596 | | - gnc_gdate_set_today (&today); |
1597 | | - GDateYear year_now = g_date_get_year (&today); |
1598 | | - fiscal_end_date = g_date_new (); |
1599 | | - g_date_set_dmy (fiscal_end_date, 31, GDateMonth(12), year_now); |
| 1596 | + auto ymd = GncDate().year_month_day(); |
| 1597 | + GDate end_this_year; |
| 1598 | + g_date_set_dmy (&end_this_year, 31, GDateMonth(12), ymd.year); |
| 1599 | + gnc_pricedb_process_removal_list (db, &end_this_year, data, keep); |
1600 | 1600 | } |
1601 | | - else if (g_date_valid (fiscal_end_date) == FALSE) |
1602 | | - { |
1603 | | - GDate today; |
1604 | | - gnc_gdate_set_today (&today); |
1605 | | - GDateYear year_now = g_date_get_year (&today); |
1606 | | - g_date_clear (fiscal_end_date, 1); |
1607 | | - g_date_set_dmy (fiscal_end_date, 31, GDateMonth(12), year_now); |
1608 | | - } |
1609 | | - gnc_pricedb_process_removal_list (db, fiscal_end_date, data, keep); |
| 1601 | + else |
| 1602 | + gnc_pricedb_process_removal_list (db, fiscal_end_date, data, keep); |
1610 | 1603 |
|
1611 | 1604 | g_slist_free (data.list); |
1612 | 1605 | LEAVE(" "); |
|
0 commit comments