From 6f89bd62b3cf7089fb10c1c1ed908f0d9b5cc31c Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 31 Jul 2018 14:43:27 -0700 Subject: [PATCH] Remove timespec from gnucash/gnome. With a little API bleed into engine. --- gnucash/gnome/assistant-acct-period.c | 3 - gnucash/gnome/assistant-stock-split.c | 7 +-- gnucash/gnome/dialog-date-close.c | 32 +++++------ gnucash/gnome/dialog-date-close.h | 6 +- gnucash/gnome/dialog-invoice.c | 22 ++++---- gnucash/gnome/dialog-order.c | 6 +- gnucash/gnome/dialog-payment.c | 8 +-- gnucash/gnome/dialog-price-edit-db.c | 66 ++++++++++++---------- gnucash/gnome/dialog-price-editor.c | 16 +++--- gnucash/gnome/dialog-trans-assoc.c | 13 +++-- libgnucash/engine/gnc-pricedb.c | 12 ++-- libgnucash/engine/gnc-pricedb.h | 2 +- libgnucash/engine/gncInvoice.c | 6 +- libgnucash/engine/gncOwner.c | 6 +- libgnucash/engine/gncOwner.h | 4 +- libgnucash/engine/test/utest-gnc-pricedb.c | 6 +- 16 files changed, 107 insertions(+), 108 deletions(-) diff --git a/gnucash/gnome/assistant-acct-period.c b/gnucash/gnome/assistant-acct-period.c index 87a503ae55..06e9bb4ed2 100644 --- a/gnucash/gnome/assistant-acct-period.c +++ b/gnucash/gnome/assistant-acct-period.c @@ -465,7 +465,6 @@ ap_assistant_finish (GtkAssistant *assistant, gpointer user_data) gint len; const char *btitle; char *bnotes; - Timespec closing_date; ENTER("info=%p", info); @@ -478,8 +477,6 @@ ap_assistant_finish (GtkAssistant *assistant, gpointer user_data) bnotes = gtk_text_buffer_get_text(buffer, &startiter, &enditer , 0); PINFO("Book title is - %s\n", btitle); - timespecFromTime64 (&closing_date, - gnc_time64_get_day_end_gdate (&info->closing_date)); g_free(bnotes); /* Report the status back to the user. */ diff --git a/gnucash/gnome/assistant-stock-split.c b/gnucash/gnome/assistant-stock-split.c index 287a4375a4..77fb8b3334 100644 --- a/gnucash/gnome/assistant-stock-split.c +++ b/gnucash/gnome/assistant-stock-split.c @@ -388,19 +388,14 @@ gnc_stock_split_assistant_finish (GtkAssistant *assistant, GNCPrice *price; GNCPriceDB *pdb; GNCCurrencyEdit *ce; - Timespec ts; ce = GNC_CURRENCY_EDIT (info->price_currency_edit); - - ts.tv_sec = date; - ts.tv_nsec = 0; - price = gnc_price_create (gnc_get_current_book ()); gnc_price_begin_edit (price); gnc_price_set_commodity (price, xaccAccountGetCommodity (account)); gnc_price_set_currency (price, gnc_currency_edit_get_currency (ce)); - gnc_price_set_time (price, ts); + gnc_price_set_time64 (price, date); gnc_price_set_source (price, PRICE_SOURCE_STOCK_SPLIT); gnc_price_set_typestr (price, PRICE_TYPE_UNK); gnc_price_set_value (price, amount); diff --git a/gnucash/gnome/dialog-date-close.c b/gnucash/gnome/dialog-date-close.c index 6a34d805c5..977a63796d 100644 --- a/gnucash/gnome/dialog-date-close.c +++ b/gnucash/gnome/dialog-date-close.c @@ -45,7 +45,7 @@ typedef struct _dialog_date_close_window GtkWidget *memo_entry; GtkWidget *question_check; GncBillTerm *terms; - Timespec *ts, *ts2; + time64 t, t2; GList * acct_types; GList * acct_commodities; QofBook *book; @@ -87,14 +87,14 @@ gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data) } if (ddc->post_date) - ddc->ts2->tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (ddc->post_date)); + ddc->t2 = gnc_date_edit_get_date (GNC_DATE_EDIT (ddc->post_date)); if (ddc->date) { if (ddc->terms) - ddc->ts->tv_sec = gncBillTermComputeDueDate (ddc->terms, ddc->ts2->tv_sec); + ddc->t = gncBillTermComputeDueDate (ddc->terms, ddc->t2); else - ddc->ts->tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (ddc->date)); + ddc->t = gnc_date_edit_get_date (GNC_DATE_EDIT (ddc->date)); } if (ddc->memo_entry && ddc->memo) @@ -122,7 +122,7 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message, const char *label_message, gboolean ok_is_default, /* Returned data ... */ - Timespec *ts) + time64 *t) { DialogDateClose *ddc; GtkWidget *date_box; @@ -130,11 +130,11 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message, GtkBuilder *builder; gboolean retval; - if (!message || !label_message || !ts) + if (!message || !label_message || !t) return FALSE; ddc = g_new0 (DialogDateClose, 1); - ddc->ts = ts; + ddc->t = *t; builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-date-close.glade", "date_close_dialog"); @@ -146,7 +146,7 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message, date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_box")); ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE); gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0); - gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->date), ts->tv_sec); + gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->date), *t); if (parent) gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent)); @@ -203,7 +203,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, GList * acct_types, GList * acct_commodities, QofBook *book, GncBillTerm *terms, /* Returned Data... */ - Timespec *ddue, Timespec *post, + time64 *ddue, time64 *post, char **memo, Account **acct, gboolean *answer) { DialogDateClose *ddc; @@ -220,8 +220,8 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, return FALSE; ddc = g_new0 (DialogDateClose, 1); - ddc->ts = ddue; - ddc->ts2 = post; + ddc->t = *ddue; + ddc->t2 = *post; ddc->book = book; ddc->acct_types = acct_types; ddc->acct_commodities = acct_commodities; @@ -278,7 +278,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, /* Set the post date widget */ - gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->post_date), post->tv_sec); + gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->post_date), *post); /* Deal with the terms handling of the due date */ if (terms) @@ -289,7 +289,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, post_date_changed_cb (GNC_DATE_EDIT (ddc->post_date), ddc); } else - gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->date), ddue->tv_sec); + gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->date), *ddue); /* Setup the account widget */ fill_in_acct_info (ddc, set_default_acct); @@ -329,7 +329,7 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, gboolean ok_is_default, GList * acct_types, QofBook *book, /* Returned Data... */ - Timespec *date, Account **acct) + time64 *date, Account **acct) { DialogDateClose *ddc; GtkLabel *label; @@ -343,7 +343,7 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, return FALSE; ddc = g_new0 (DialogDateClose, 1); - ddc->ts = date; + ddc->t = *date; ddc->book = book; ddc->acct_types = acct_types; ddc->acct = *acct; @@ -378,7 +378,7 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, gtk_label_set_text (label, acct_label_message); /* Set the date widget */ - gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->date), date->tv_sec); + gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->date), *date); /* Setup the account widget */ fill_in_acct_info (ddc, FALSE); diff --git a/gnucash/gnome/dialog-date-close.h b/gnucash/gnome/dialog-date-close.h index 03d33f0714..757113e532 100644 --- a/gnucash/gnome/dialog-date-close.h +++ b/gnucash/gnome/dialog-date-close.h @@ -33,7 +33,7 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message, const char *label_message, gboolean ok_is_default, /* Returned data ... */ - Timespec *date); + time64 *date); /* @@ -55,7 +55,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, GList * acct_types, GList * acct_commodities, QofBook *book, GncBillTerm *terms, /* Returned Data... */ - Timespec *ddue, Timespec *post, + time64 *ddue, time64 *post, char **memo, Account **acct, gboolean *answer); @@ -66,6 +66,6 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, gboolean ok_is_default, GList * acct_types, QofBook *book, /* Returned Data... */ - Timespec *date, Account **acct); + time64 *date, Account **acct); #endif /* _DIALOG_DATE_CLOSE_H */ diff --git a/gnucash/gnome/dialog-invoice.c b/gnucash/gnome/dialog-invoice.c index f1cb06a295..8c2ece9f8f 100644 --- a/gnucash/gnome/dialog-invoice.c +++ b/gnucash/gnome/dialog-invoice.c @@ -686,7 +686,7 @@ gnc_invoice_window_printCB (GtkWindow* parent, gpointer data) static gboolean gnc_dialog_post_invoice(InvoiceWindow *iw, char *message, - Timespec *ddue, Timespec *postdate, + time64 *ddue, time64 *postdate, char **memo, Account **acc, gboolean *accumulate) { GncInvoice *invoice; @@ -719,17 +719,17 @@ gnc_dialog_post_invoice(InvoiceWindow *iw, char *message, * For Vendor Bills and Employee Vouchers * that would be the date of the most recent invoice entry. * Failing that, today is used as a fallback */ - *postdate = timespec_now(); + *postdate = gnc_time(NULL); if (entries && ((gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR) || (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_EMPLOYEE))) { - postdate->tv_sec = gncEntryGetDate ((GncEntry*)entries->data); + *postdate = gncEntryGetDate ((GncEntry*)entries->data); for (entries_iter = entries; entries_iter != NULL; entries_iter = g_list_next(entries_iter)) { time64 entrydate = gncEntryGetDate ((GncEntry*)entries_iter->data); - if (entrydate > postdate->tv_sec) - postdate->tv_sec = entrydate; + if (entrydate > *postdate) + *postdate = entrydate; } } @@ -758,8 +758,8 @@ gnc_dialog_post_invoice(InvoiceWindow *iw, char *message, struct post_invoice_params { - Timespec ddue; /* Due date */ - Timespec postdate; /* Date posted */ + time64 ddue; /* Due date */ + time64 postdate; /* Date posted */ char *memo; /* Memo for posting transaction */ Account *acc; /* Account to post to */ gboolean accumulate; /* Whether to accumulate splits */ @@ -772,7 +772,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params) GncInvoice *invoice; char *message, *memo; Account *acc = NULL; - Timespec ddue, postdate; + time64 ddue, postdate; gboolean accumulate; QofInstance *owner_inst; const char *text; @@ -873,7 +873,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params) xfer = gnc_xfer_dialog (iw_get_window(iw), acc); gnc_xfer_dialog_is_exchange_dialog(xfer, &exch_rate); gnc_xfer_dialog_select_to_currency(xfer, account_currency); - gnc_xfer_dialog_set_date (xfer, timespecToTime64 (postdate)); + gnc_xfer_dialog_set_date (xfer, postdate); /* Even if amount is 0 ask for an exchange rate. It's required * for the transaction generating code. Use an amount of 1 in * that case as the dialog won't allow to specify an exchange @@ -913,7 +913,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params) gnc_price_begin_edit (convprice); gnc_price_set_commodity (convprice, account_currency); gnc_price_set_currency (convprice, gncInvoiceGetCurrency (invoice)); - gnc_price_set_time (convprice, postdate); + gnc_price_set_time64 (convprice, postdate); gnc_price_set_source (convprice, PRICE_SOURCE_TEMP); gnc_price_set_typestr (convprice, PRICE_TYPE_LAST); gnc_price_set_value (convprice, exch_rate); @@ -948,7 +948,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params) else auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY); - gncInvoicePostToAccount (invoice, acc, postdate.tv_sec, ddue.tv_sec, memo, accumulate, auto_pay); + gncInvoicePostToAccount (invoice, acc, postdate, ddue, memo, accumulate, auto_pay); cleanup: gncInvoiceCommitEdit (invoice); diff --git a/gnucash/gnome/dialog-order.c b/gnucash/gnome/dialog-order.c index 1cb7cb959c..0c9bfbe00e 100644 --- a/gnucash/gnome/dialog-order.c +++ b/gnucash/gnome/dialog-order.c @@ -261,7 +261,7 @@ gnc_order_window_close_order_cb (GtkWidget *widget, gpointer data) GList *entries; char *message, *label; gboolean non_inv = FALSE; - Timespec ts = {gnc_time (NULL), 0}; + time64 t = gnc_time (NULL); /* Make sure the order is ok */ if (!gnc_order_window_verify_ok (ow)) @@ -310,10 +310,10 @@ gnc_order_window_close_order_cb (GtkWidget *widget, gpointer data) message = _("Do you really want to close the order?"); label = _("Close Date"); - if (!gnc_dialog_date_close_parented (ow->dialog, message, label, TRUE, &ts)) + if (!gnc_dialog_date_close_parented (ow->dialog, message, label, TRUE, &t)) return; - gncOrderSetDateClosed (order, ts.tv_nsec); + gncOrderSetDateClosed (order, t); /* save it off */ gnc_order_window_ok_save (ow); diff --git a/gnucash/gnome/dialog-payment.c b/gnucash/gnome/dialog-payment.c index ee6d20c5fe..39465a8619 100644 --- a/gnucash/gnome/dialog-payment.c +++ b/gnucash/gnome/dialog-payment.c @@ -921,7 +921,7 @@ gnc_payment_ok_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data) { const char *memo, *num; GDate date; - Timespec ts; + time64 t; gnc_numeric exch = gnc_numeric_create(1, 1); //default to "one to one" rate GList *selected_lots = NULL; GtkTreeSelection *selection; @@ -932,7 +932,7 @@ gnc_payment_ok_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data) num = gtk_entry_get_text (GTK_ENTRY (pw->num_entry)); g_date_clear (&date, 1); gnc_date_edit_get_gdate (GNC_DATE_EDIT (pw->date_edit), &date); - ts = gdate_to_timespec (date); + t = gdate_to_time64 (date); /* Obtain the list of selected lots (documents/payments) from the dialog */ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view)); @@ -974,8 +974,8 @@ gnc_payment_ok_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data) 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, - ts, memo, num, auto_pay); + pw->post_acct, pw->xfer_acct, pw->amount_tot, + exch, t, memo, num, auto_pay); } gnc_resume_gui_refresh (); diff --git a/gnucash/gnome/dialog-price-edit-db.c b/gnucash/gnome/dialog-price-edit-db.c index 4fdcc0971e..99835f98c3 100644 --- a/gnucash/gnome/dialog-price-edit-db.c +++ b/gnucash/gnome/dialog-price-edit-db.c @@ -223,7 +223,7 @@ gnc_prices_dialog_remove_clicked (GtkWidget *widget, gpointer data) /** Enumeration for the price delete list-store */ enum GncPriceColumn {PRICED_FULL_NAME, PRICED_COMM, PRICED_DATE, PRICED_COUNT}; -static Timespec +static time64 gnc_prices_dialog_load_view (GtkTreeView *view, GNCPriceDB *pdb) { GtkTreeModel *model = gtk_tree_view_get_model (view); @@ -234,8 +234,7 @@ gnc_prices_dialog_load_view (GtkTreeView *view, GNCPriceDB *pdb) GList *commodity_list = NULL; GtkTreeIter iter; - Timespec oldest_ts = timespec_now (); - oldest_ts.tv_nsec = 0; + time64 oldest = gnc_time (NULL); namespace_list = g_list_first (namespace_list); while (namespace_list != NULL) @@ -256,14 +255,13 @@ gnc_prices_dialog_load_view (GtkTreeView *view, GNCPriceDB *pdb) PriceList *list = gnc_pricedb_get_prices (pdb, tmp_commodity, NULL); GList *node = g_list_last (list); GNCPrice *price = (GNCPrice*)node->data; - Timespec price_ts = gnc_price_get_time (price); + time64 price_time = gnc_price_get_time64 (price); const gchar *name_str = gnc_commodity_get_printname (tmp_commodity); gchar *date_str, *num_str; + if (oldest > price_time) + oldest = price_time; - if (timespec_cmp(&oldest_ts, &price_ts) >= 0) - oldest_ts.tv_sec = price_ts.tv_sec; - - date_str = g_strdup (gnc_print_date (price_ts)); + date_str = qof_print_date (price_time); num_str = g_strdup_printf ("%d", num); gtk_list_store_append (GTK_LIST_STORE(model), &iter); @@ -282,7 +280,7 @@ gnc_prices_dialog_load_view (GtkTreeView *view, GNCPriceDB *pdb) g_list_free (commodity_list); g_list_free (namespace_list); - return oldest_ts; + return oldest; } static GList * @@ -371,15 +369,16 @@ selection_changed_cb (GtkTreeSelection *selection, gpointer data) static GDate get_fiscal_end_date (void) { - Timespec ts_end; - GDate f_end; + time64 end; + char datebuff[MAX_DATE_LENGTH + 1]; + memset (datebuff, 0, sizeof(datebuff)); + end = gnc_accounting_period_fiscal_end(); + qof_print_date_buff(datebuff, sizeof(datebuff), + gnc_accounting_period_fiscal_end()); + PINFO("Fiscal end date is %s", datebuff); - timespecFromTime64 (&ts_end, gnc_accounting_period_fiscal_end()); - f_end = timespec_to_gdate (ts_end); + return time64_to_gdate (end); - PINFO("Fiscal end date is %s", qof_print_date (gnc_accounting_period_fiscal_end())); - - return f_end; } void @@ -393,7 +392,7 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data) GtkTreeSelection *selection; GtkTreeViewColumn *tree_column; GtkCellRenderer *cr; - Timespec first_ts; + time64 first; gint result; ENTER(" "); @@ -430,7 +429,7 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data) gtk_cell_renderer_set_alignment (cr, 0.5, 0.5); // Load the view and get the earliest date - first_ts = gnc_prices_dialog_load_view (pdb_dialog->remove_view, pdb_dialog->price_db); + first = gnc_prices_dialog_load_view (pdb_dialog->remove_view, pdb_dialog->price_db); gtk_tree_selection_select_all (selection); g_signal_connect (selection, "changed", G_CALLBACK(selection_changed_cb), pdb_dialog); @@ -455,7 +454,7 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data) // Are you sure you want to delete the entries and we have commodities if ((g_list_length (comm_list) != 0) && (gnc_verify_dialog (GTK_WINDOW (pdb_dialog->remove_dialog), FALSE, fmt, NULL))) { - Timespec last_ts; + time64 last; GDate fiscal_end_date = get_fiscal_end_date (); PriceRemoveSourceFlags source = PRICE_REMOVE_SOURCE_FQ; PriceRemoveKeepOptions keep = PRICE_REMOVE_KEEP_NONE; @@ -466,8 +465,7 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data) gtk_tree_view_set_model (GTK_TREE_VIEW(pdb_dialog->price_tree), NULL); DEBUG("deleting prices"); - last_ts.tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (date)); - last_ts.tv_nsec = 0; + last = gnc_date_edit_get_date (GNC_DATE_EDIT (date)); button = GTK_WIDGET(gtk_builder_get_object (builder, "radiobutton_last_week")); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) @@ -486,23 +484,29 @@ gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data) keep = PRICE_REMOVE_KEEP_SCALED; if (keep != PRICE_REMOVE_KEEP_SCALED) - gnc_pricedb_remove_old_prices (pdb_dialog->price_db, comm_list, &fiscal_end_date, - last_ts, pdb_dialog->remove_source, keep); + gnc_pricedb_remove_old_prices (pdb_dialog->price_db, comm_list, + &fiscal_end_date, + last, pdb_dialog->remove_source, + keep); else { - Timespec tmp_ts; - GDate tmp_date = timespec_to_gdate (last_ts); + time64 tmp; + GDate tmp_date = time64_to_gdate (last); g_date_subtract_months (&tmp_date, 6); - tmp_ts = gdate_to_timespec (tmp_date); + tmp = gdate_to_time64 (tmp_date); - gnc_pricedb_remove_old_prices (pdb_dialog->price_db, comm_list, &fiscal_end_date, tmp_ts, - pdb_dialog->remove_source, PRICE_REMOVE_KEEP_LAST_WEEKLY); + gnc_pricedb_remove_old_prices (pdb_dialog->price_db, comm_list, + &fiscal_end_date, tmp, + pdb_dialog->remove_source, + PRICE_REMOVE_KEEP_LAST_WEEKLY); g_date_subtract_months (&tmp_date, 6); - tmp_ts = gdate_to_timespec (tmp_date); + tmp = gdate_to_time64 (tmp_date); - gnc_pricedb_remove_old_prices (pdb_dialog->price_db, comm_list, &fiscal_end_date, tmp_ts, - pdb_dialog->remove_source, PRICE_REMOVE_KEEP_LAST_MONTHLY); + gnc_pricedb_remove_old_prices (pdb_dialog->price_db, comm_list, + &fiscal_end_date, tmp, + pdb_dialog->remove_source, + PRICE_REMOVE_KEEP_LAST_MONTHLY); } // reconnect the model to the price treeview gtk_tree_view_set_model (GTK_TREE_VIEW(pdb_dialog->price_tree), model); diff --git a/gnucash/gnome/dialog-price-editor.c b/gnucash/gnome/dialog-price-editor.c index 5b474c6e07..e6ccfa184f 100644 --- a/gnucash/gnome/dialog-price-editor.c +++ b/gnucash/gnome/dialog-price-editor.c @@ -143,7 +143,7 @@ price_to_gui (PriceEditDialog *pedit_dialog) const char *source; const char *type; gnc_numeric value; - Timespec date; + time64 date; if (pedit_dialog->price) { @@ -160,7 +160,7 @@ price_to_gui (PriceEditDialog *pedit_dialog) name_space, fullname); currency = gnc_price_get_currency (pedit_dialog->price); - date = gnc_price_get_time (pedit_dialog->price); + date = gnc_price_get_time64 (pedit_dialog->price); source = gnc_price_get_source_string (pedit_dialog->price); type = gnc_price_get_typestr (pedit_dialog->price); value = gnc_price_get_value (pedit_dialog->price); @@ -168,8 +168,7 @@ price_to_gui (PriceEditDialog *pedit_dialog) else { currency = gnc_default_currency (); - date.tv_sec = gnc_time (NULL); - date.tv_nsec = 0; + date = gnc_time (NULL); source = "user:price-editor"; //Sync with source_names in gnc-pricedb.c type = ""; value = gnc_numeric_zero (); @@ -182,7 +181,7 @@ price_to_gui (PriceEditDialog *pedit_dialog) (GNC_CURRENCY_EDIT (pedit_dialog->currency_edit), currency); } - gnc_date_edit_set_time (GNC_DATE_EDIT (pedit_dialog->date_edit), date.tv_sec); + gnc_date_edit_set_time (GNC_DATE_EDIT (pedit_dialog->date_edit), date); gtk_entry_set_text (GTK_ENTRY (pedit_dialog->source_entry), source); @@ -203,7 +202,7 @@ gui_to_price (PriceEditDialog *pedit_dialog) const char *source; const char *type; gnc_numeric value; - Timespec date; + time64 date; name_space = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbwe); fullname = gtk_entry_get_text( GTK_ENTRY( gtk_bin_get_child( GTK_BIN( GTK_COMBO_BOX(pedit_dialog->commodity_cbwe))))); @@ -217,8 +216,7 @@ gui_to_price (PriceEditDialog *pedit_dialog) if (!currency) return _("You must select a Currency."); - date.tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (pedit_dialog->date_edit)); - date.tv_nsec = 0; + date = gnc_date_edit_get_date (GNC_DATE_EDIT (pedit_dialog->date_edit)); source = gtk_entry_get_text (GTK_ENTRY (pedit_dialog->source_entry)); @@ -236,7 +234,7 @@ gui_to_price (PriceEditDialog *pedit_dialog) gnc_price_begin_edit (pedit_dialog->price); gnc_price_set_commodity (pedit_dialog->price, commodity); gnc_price_set_currency (pedit_dialog->price, currency); - gnc_price_set_time (pedit_dialog->price, date); + gnc_price_set_time64 (pedit_dialog->price, date); gnc_price_set_source_string (pedit_dialog->price, source); gnc_price_set_typestr (pedit_dialog->price, type); gnc_price_set_value (pedit_dialog->price, value); diff --git a/gnucash/gnome/dialog-trans-assoc.c b/gnucash/gnome/dialog-trans-assoc.c index 9429a32dc0..0c1eab8a79 100644 --- a/gnucash/gnome/dialog-trans-assoc.c +++ b/gnucash/gnome/dialog-trans-assoc.c @@ -336,11 +336,12 @@ get_trans_info (AssocDialog *assoc_dialog) { gchar *uri_u; gboolean rel = FALSE; - Timespec ts = {xaccTransRetDatePosted (trans),0}; - - if (ts.tv_sec == 0) - ts.tv_sec = gnc_time (NULL); - + time64 t = xaccTransRetDatePosted (trans); + char datebuff[MAX_DATE_LENGTH + 1]; + memset (datebuff, 0, sizeof(datebuff)); + if (t == 0) + t = gnc_time (NULL); + qof_print_date_buff (datebuff, sizeof(datebuff), t); gtk_list_store_append (GTK_LIST_STORE(model), &iter); if (g_str_has_prefix (uri,"file:/") && !g_str_has_prefix (uri,"file://")) // path is relative @@ -349,7 +350,7 @@ get_trans_info (AssocDialog *assoc_dialog) uri_u = convert_uri_to_unescaped (assoc_dialog, uri); gtk_list_store_set (GTK_LIST_STORE(model), &iter, - DATE_TRANS, gnc_print_date (ts), + DATE_TRANS, datebuff, DESC_TRANS, xaccTransGetDescription (trans), URI_U, uri_u, AVAILABLE, _("Unknown"), URI_SPLIT, split, URI, uri, diff --git a/libgnucash/engine/gnc-pricedb.c b/libgnucash/engine/gnc-pricedb.c index daa0aa7785..d1485707bd 100644 --- a/libgnucash/engine/gnc-pricedb.c +++ b/libgnucash/engine/gnc-pricedb.c @@ -1327,7 +1327,7 @@ gnc_pricedb_remove_price(GNCPriceDB *db, GNCPrice *p) typedef struct { GNCPriceDB *db; - Timespec cutoff; + time64 cutoff; gboolean delete_fq; gboolean delete_user; gboolean delete_app; @@ -1365,7 +1365,7 @@ check_one_price_date (GNCPrice *price, gpointer user_data) gnc_timespec_to_iso8601_buff(pt , buf); DEBUG("checking date %s", buf); } - if (timespec_cmp (&pt, &data->cutoff) < 0) + if (pt.tv_sec < data->cutoff) { data->list = g_slist_prepend(data->list, price); DEBUG("will delete"); @@ -1625,12 +1625,14 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date, gboolean gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list, - GDate *fiscal_end_date, Timespec cutoff, + GDate *fiscal_end_date, time64 cutoff, PriceRemoveSourceFlags source, PriceRemoveKeepOptions keep) { remove_info data; GList *node; + char datebuff[MAX_DATE_LENGTH + 1]; + memset (datebuff, sizeof(datebuff), 0); data.db = db; data.cutoff = cutoff; @@ -1663,7 +1665,9 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list, LEAVE("Empty price list"); return FALSE; } - DEBUG("Number of Prices in list is %d, Cutoff date is %s", g_slist_length (data.list), gnc_print_date (cutoff)); + qof_print_date_buff (datebuff, sizeof(datebuff), cutoff); + DEBUG("Number of Prices in list is %d, Cutoff date is %s", + g_slist_length (data.list), datebuff); // Check for a valid fiscal end of year date if (fiscal_end_date == NULL) diff --git a/libgnucash/engine/gnc-pricedb.h b/libgnucash/engine/gnc-pricedb.h index 3f0b65efb4..61ed2c943f 100644 --- a/libgnucash/engine/gnc-pricedb.h +++ b/libgnucash/engine/gnc-pricedb.h @@ -406,7 +406,7 @@ typedef enum * @return True if there were prices to process, False if not. */ gboolean gnc_pricedb_remove_old_prices(GNCPriceDB *db, GList *comm_list, - GDate *fiscal_end_date, Timespec cutoff, + GDate *fiscal_end_date, time64 cutoff, PriceRemoveSourceFlags source, PriceRemoveKeepOptions keep); diff --git a/libgnucash/engine/gncInvoice.c b/libgnucash/engine/gncInvoice.c index 60f643a7b9..40d87be98e 100644 --- a/libgnucash/engine/gncInvoice.c +++ b/libgnucash/engine/gncInvoice.c @@ -1935,7 +1935,6 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn, GNCLot *payment_lot; GList *selected_lots = NULL; const GncOwner *owner; - Timespec ts_pass = {date,0}; /* Verify our arguments */ if (!invoice || !gncInvoiceIsPosted (invoice) || !xfer_acc) return; @@ -1944,8 +1943,9 @@ 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, ts_pass, memo, num); + payment_lot = gncOwnerCreatePaymentLot (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/gncOwner.c b/libgnucash/engine/gncOwner.c index 56b603622a..60119361e2 100644 --- a/libgnucash/engine/gncOwner.c +++ b/libgnucash/engine/gncOwner.c @@ -725,7 +725,7 @@ 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, Timespec date, + gnc_numeric amount, gnc_numeric exch, time64 date, const char *memo, const char *num) { QofBook *book; @@ -814,7 +814,7 @@ gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction **preset_txn, /* set per book option */ xaccTransSetCurrency (txn, commodity); xaccTransSetDateEnteredSecs (txn, gnc_time (NULL)); - xaccTransSetDatePostedSecs (txn, date.tv_sec); + xaccTransSetDatePostedSecs (txn, date); /* The split for the transfer account */ @@ -1378,7 +1378,7 @@ void gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots) void gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn, GList *lots, Account *posted_acc, Account *xfer_acc, - gnc_numeric amount, gnc_numeric exch, Timespec date, + gnc_numeric amount, gnc_numeric exch, time64 date, const char *memo, const char *num, gboolean auto_pay) { GNCLot *payment_lot = NULL; diff --git a/libgnucash/engine/gncOwner.h b/libgnucash/engine/gncOwner.h index 1542f9807f..79bbaba39a 100644 --- a/libgnucash/engine/gncOwner.h +++ b/libgnucash/engine/gncOwner.h @@ -216,7 +216,7 @@ gboolean gncOwnerGetOwnerFromTypeGuid (QofBook *book, GncOwner *owner, QofIdType GNCLot * gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction **preset_txn, Account *posted_acc, Account *xfer_acc, - gnc_numeric amount, gnc_numeric exch, Timespec date, + gnc_numeric amount, gnc_numeric exch, time64 date, const char *memo, const char *num); /** @@ -269,7 +269,7 @@ void gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots); void gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn, GList *lots, Account *posted_acc, Account *xfer_acc, - gnc_numeric amount, gnc_numeric exch, Timespec date, + 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 diff --git a/libgnucash/engine/test/utest-gnc-pricedb.c b/libgnucash/engine/test/utest-gnc-pricedb.c index 345a34dbc6..841260aba5 100644 --- a/libgnucash/engine/test/utest-gnc-pricedb.c +++ b/libgnucash/engine/test/utest-gnc-pricedb.c @@ -789,9 +789,9 @@ static void test_gnc_pricedb_remove_old_prices (PriceDBFixture *fixture, gconstp PRICE_REMOVE_SOURCE_USER | PRICE_REMOVE_SOURCE_APP; - Timespec t_cut = gnc_dmy2timespec(1, 1, 2008); - Timespec t_cut1 = gnc_dmy2timespec(1, 1, 2009); - Timespec t_cut2 = gnc_dmy2timespec(1, 1, 2010); + time64 t_cut = gnc_dmy2time64(1, 1, 2008); + time64 t_cut1 = gnc_dmy2time64(1, 1, 2009); + time64 t_cut2 = gnc_dmy2time64(1, 1, 2010); GDate *fiscal_end_date = g_date_new (); g_date_set_dmy (fiscal_end_date, 31, 12, 2017);