From 92a8cf330aece720dd02cc85d181d3bffbcaee08 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 2 Aug 2018 13:55:24 -0700 Subject: [PATCH] Timespec->time64 in business code. --- gnucash/gnome/dialog-payment.c | 6 +++--- libgnucash/engine/gncBillTerm.c | 17 ++++++++--------- libgnucash/engine/gncEntry.c | 12 ++++++------ libgnucash/engine/gncInvoice.c | 7 ++++--- libgnucash/engine/gncInvoice.h | 2 +- libgnucash/engine/gncOwner.c | 22 ++++++++++++---------- libgnucash/engine/gncOwner.h | 16 ++++++++-------- libgnucash/engine/gncTaxTable.c | 9 ++++----- libgnucash/engine/gncTaxTable.h | 4 ++-- 9 files changed, 48 insertions(+), 47 deletions(-) diff --git a/gnucash/gnome/dialog-payment.c b/gnucash/gnome/dialog-payment.c index 39465a8619..ef3a9ea401 100644 --- a/gnucash/gnome/dialog-payment.c +++ b/gnucash/gnome/dialog-payment.c @@ -973,9 +973,9 @@ gnc_payment_ok_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data) else auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY); - gncOwnerApplyPayment (&pw->owner, &(pw->tx_info->txn), selected_lots, - pw->post_acct, pw->xfer_acct, pw->amount_tot, - exch, t, memo, num, auto_pay); + gncOwnerApplyPaymentSecs (&pw->owner, &(pw->tx_info->txn), selected_lots, + pw->post_acct, pw->xfer_acct, pw->amount_tot, + exch, t, memo, num, auto_pay); } gnc_resume_gui_refresh (); diff --git a/libgnucash/engine/gncBillTerm.c b/libgnucash/engine/gncBillTerm.c index 73e19d7f8d..93c03f6a74 100644 --- a/libgnucash/engine/gncBillTerm.c +++ b/libgnucash/engine/gncBillTerm.c @@ -764,7 +764,7 @@ compute_monthyear (const GncBillTerm *term, time64 post_date, gnc_localtime_r (&post_date, &tm); iday = tm.tm_mday; imonth = tm.tm_mon + 1; - iyear = tm.tm_year + 1; + iyear = tm.tm_year + 1900; if (cutoff <= 0) cutoff += gnc_date_get_last_mday (imonth - 1, iyear); @@ -801,23 +801,23 @@ compute_monthyear (const GncBillTerm *term, time64 post_date, * detailed explanation of proximo. */ -static Timespec -compute_time (const GncBillTerm *term, Timespec post_date, int days) +static time64 +compute_time (const GncBillTerm *term, time64 post_date, int days) { - Timespec res = post_date; + time64 res = post_date; int day, month, year; switch (term->type) { case GNC_TERM_TYPE_DAYS: - res.tv_sec += (SECS_PER_DAY * days); + res += (SECS_PER_DAY * days); break; case GNC_TERM_TYPE_PROXIMO: - compute_monthyear (term, post_date.tv_sec, &month, &year); + compute_monthyear (term, post_date, &month, &year); day = gnc_date_get_last_mday (month - 1, year); if (days < day) day = days; - res = gnc_dmy2timespec (day, month, year); + res = gnc_dmy2time64 (day, month, year); break; } return res; @@ -826,9 +826,8 @@ compute_time (const GncBillTerm *term, Timespec post_date, int days) time64 gncBillTermComputeDueDate (const GncBillTerm *term, time64 post_date) { - Timespec pass = {post_date, 0}; if (!term) return post_date; - return compute_time (term, pass, term->due_days).tv_sec; + return compute_time (term, post_date, term->due_days); } /* Package-Private functions */ diff --git a/libgnucash/engine/gncEntry.c b/libgnucash/engine/gncEntry.c index a47fd3b1fb..654e7ec4ea 100644 --- a/libgnucash/engine/gncEntry.c +++ b/libgnucash/engine/gncEntry.c @@ -1324,20 +1324,20 @@ gncEntryRecomputeValues (GncEntry *entry) /* See if either tax table changed since we last computed values */ if (entry->i_tax_table) { - Timespec modtime = gncTaxTableLastModified (entry->i_tax_table); - if (entry->i_taxtable_modtime != modtime.tv_sec) + time64 modtime = gncTaxTableLastModifiedSecs (entry->i_tax_table); + if (entry->i_taxtable_modtime != modtime) { entry->values_dirty = TRUE; - entry->i_taxtable_modtime = modtime.tv_sec; + entry->i_taxtable_modtime = modtime; } } if (entry->b_tax_table) { - Timespec modtime = gncTaxTableLastModified (entry->b_tax_table); - if (entry->b_taxtable_modtime == modtime.tv_sec) + time64 modtime = gncTaxTableLastModifiedSecs (entry->b_tax_table); + if (entry->b_taxtable_modtime == modtime) { entry->values_dirty = TRUE; - entry->b_taxtable_modtime = modtime.tv_sec; + entry->b_taxtable_modtime = modtime; } } diff --git a/libgnucash/engine/gncInvoice.c b/libgnucash/engine/gncInvoice.c index 40d87be98e..670242c905 100644 --- a/libgnucash/engine/gncInvoice.c +++ b/libgnucash/engine/gncInvoice.c @@ -1943,9 +1943,10 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn, g_return_if_fail (owner->owner.undefined); /* Create a lot for this payment */ - payment_lot = gncOwnerCreatePaymentLot (owner, &txn, invoice->posted_acc, - xfer_acc, amount, exch, - date, memo, num); + payment_lot = gncOwnerCreatePaymentLotSecs (owner, &txn, + invoice->posted_acc, + xfer_acc, amount, exch, + date, memo, num); /* Select the invoice as only payment candidate */ selected_lots = g_list_prepend (selected_lots, invoice->posted_lot); diff --git a/libgnucash/engine/gncInvoice.h b/libgnucash/engine/gncInvoice.h index fce06f21a5..4fc2e527e1 100644 --- a/libgnucash/engine/gncInvoice.h +++ b/libgnucash/engine/gncInvoice.h @@ -246,7 +246,7 @@ gncInvoiceAutoApplyPayments (GncInvoice *invoice); * or payments for the owner will be considered * to balance the payment. * - * This code is actually a convenience wrapper around gncOwnerCreatePaymentLot + * This code is actually a convenience wrapper around gncOwnerCreatePaymentLotSecs * and gncOwnerAutoApplyPaymentsWithLots. See their descriptions for more * details on what happens exactly. */ diff --git a/libgnucash/engine/gncOwner.c b/libgnucash/engine/gncOwner.c index 60119361e2..a409b79340 100644 --- a/libgnucash/engine/gncOwner.c +++ b/libgnucash/engine/gncOwner.c @@ -723,10 +723,10 @@ gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB) } GNCLot * -gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction **preset_txn, - Account *posted_acc, Account *xfer_acc, - gnc_numeric amount, gnc_numeric exch, time64 date, - const char *memo, const char *num) +gncOwnerCreatePaymentLotSecs (const GncOwner *owner, Transaction **preset_txn, + Account *posted_acc, Account *xfer_acc, + gnc_numeric amount, gnc_numeric exch, time64 date, + const char *memo, const char *num) { QofBook *book; Split *split; @@ -1376,10 +1376,10 @@ void gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots) * then all open lots for the owner are considered. */ void -gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn, GList *lots, - Account *posted_acc, Account *xfer_acc, - gnc_numeric amount, gnc_numeric exch, time64 date, - const char *memo, const char *num, gboolean auto_pay) +gncOwnerApplyPaymentSecs (const GncOwner *owner, Transaction **preset_txn, + GList *lots, Account *posted_acc, Account *xfer_acc, + gnc_numeric amount, gnc_numeric exch, time64 date, + const char *memo, const char *num, gboolean auto_pay) { GNCLot *payment_lot = NULL; GList *selected_lots = NULL; @@ -1391,8 +1391,10 @@ gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn, GList *lo /* If there's a real amount to transfer create a lot for this payment */ if (!gnc_numeric_zero_p (amount)) - payment_lot = gncOwnerCreatePaymentLot (owner, preset_txn, posted_acc, xfer_acc, - amount, exch, date, memo, num); + payment_lot = gncOwnerCreatePaymentLotSecs (owner, preset_txn, + posted_acc, xfer_acc, + amount, exch, date, memo, + num); if (lots) selected_lots = lots; diff --git a/libgnucash/engine/gncOwner.h b/libgnucash/engine/gncOwner.h index 79bbaba39a..28251ac335 100644 --- a/libgnucash/engine/gncOwner.h +++ b/libgnucash/engine/gncOwner.h @@ -214,10 +214,10 @@ gboolean gncOwnerGetOwnerFromTypeGuid (QofBook *book, GncOwner *owner, QofIdType * split in the transfer account). */ GNCLot * -gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction **preset_txn, - Account *posted_acc, Account *xfer_acc, - gnc_numeric amount, gnc_numeric exch, time64 date, - const char *memo, const char *num); +gncOwnerCreatePaymentLotSecs (const GncOwner *owner, Transaction **preset_txn, + Account *posted_acc, Account *xfer_acc, + gnc_numeric amount, gnc_numeric exch, time64 date, + const char *memo, const char *num); /** * Given a list of lots, try to balance as many of them as possible @@ -267,10 +267,10 @@ void gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots); * details on what happens exactly. */ void -gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn, GList *lots, - Account *posted_acc, Account *xfer_acc, - gnc_numeric amount, gnc_numeric exch, time64 date, - const char *memo, const char *num, gboolean auto_pay); +gncOwnerApplyPaymentSecs (const GncOwner *owner, Transaction **preset_txn, + GList *lots, Account *posted_acc, Account *xfer_acc, + gnc_numeric amount, gnc_numeric exch, time64 date, + const char *memo, const char *num, gboolean auto_pay); /** Helper function to find a split in lot that best offsets target_value * Obviously it should be of opposite sign. diff --git a/libgnucash/engine/gncTaxTable.c b/libgnucash/engine/gncTaxTable.c index f691f70b68..91752163eb 100644 --- a/libgnucash/engine/gncTaxTable.c +++ b/libgnucash/engine/gncTaxTable.c @@ -39,7 +39,7 @@ struct _gncTaxTable QofInstance inst; char * name; GncTaxTableEntryList* entries; - Timespec modtime; /* internal date of last modtime */ + time64 modtime; /* internal date of last modtime */ /* See src/doc/business.txt for an explanation of the following */ /* Code that handles this is *identical* to that in gncBillTerm */ @@ -165,7 +165,7 @@ maybe_resort_list (GncTaxTable *table) static inline void mod_table (GncTaxTable *table) { - timespecFromTime64 (&table->modtime, gnc_time (NULL)); + table->modtime = gnc_time (NULL); } static inline void addObj (GncTaxTable *table) @@ -761,10 +761,9 @@ gint64 gncTaxTableGetRefcount (const GncTaxTable *table) return table->refcount; } -Timespec gncTaxTableLastModified (const GncTaxTable *table) +time64 gncTaxTableLastModifiedSecs (const GncTaxTable *table) { - Timespec ts = { 0 , 0 }; - if (!table) return ts; + if (!table) return 0; return table->modtime; } diff --git a/libgnucash/engine/gncTaxTable.h b/libgnucash/engine/gncTaxTable.h index 7d9579a13c..5215585e1f 100644 --- a/libgnucash/engine/gncTaxTable.h +++ b/libgnucash/engine/gncTaxTable.h @@ -41,7 +41,7 @@ is *identical* to that in ::GncBillTerm @param QofInstance inst; @param char * name; @param GncTaxTableEntryList* entries; -@param Timespec modtime; +@param time64 modtime; @param gint64 refcount; @param GncTaxTable * parent; if non-null, we are an immutable child @param GncTaxTable * child; if non-null, we have not changed @@ -162,7 +162,7 @@ GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new); typedef GList GncTaxTableEntryList; GncTaxTableEntryList* gncTaxTableGetEntries (const GncTaxTable *table); gint64 gncTaxTableGetRefcount (const GncTaxTable *table); -Timespec gncTaxTableLastModified (const GncTaxTable *table); +time64 gncTaxTableLastModifiedSecs (const GncTaxTable *table); Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry); GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry);