r21561 - gnucash/trunk/src - Use the GDate-based date setter of GncEntry where suitable instead of the timespec one.
Christian Stimming
cstim at code.gnucash.org
Fri Nov 11 16:58:21 EST 2011
Author: cstim
Date: 2011-11-11 16:58:21 -0500 (Fri, 11 Nov 2011)
New Revision: 21561
Trac: http://svn.gnucash.org/trac/changeset/21561
Modified:
gnucash/trunk/src/business/business-gnome/dialog-invoice.c
gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c
gnucash/trunk/src/business/business-ledger/gncEntryLedgerP.h
gnucash/trunk/src/plugins/bi_import/bi_import.c
Log:
Use the GDate-based date setter of GncEntry where suitable instead of the timespec one.
This fixes the time-of-day mismatch between entering a new entry
(that was using timespecCanonicalDayTime, "noon") vs. duplicating
an invoice (that was using gnc_timet_get_today_start, "start of day").
Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2011-11-11 21:58:04 UTC (rev 21560)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2011-11-11 21:58:21 UTC (rev 21561)
@@ -2451,10 +2451,10 @@
set_gncEntry_date(gpointer data, gpointer user_data)
{
GncEntry *entry = data;
- const Timespec* new_date = user_data;
+ const GDate* new_date = user_data;
//g_warning("Modifying date for entry with desc=\"%s\"", gncEntryGetDescription(entry));
- gncEntrySetDate(entry, *new_date);
+ gncEntrySetDateGDate(entry, new_date);
/*gncEntrySetDateEntered(entry, *new_date); - don't modify this
* because apparently it defines the ordering of the entries,
* which we don't want to change. */
@@ -2468,6 +2468,7 @@
Timespec new_date;
gchar *new_id;
GList *node;
+ GDate new_date_gdate;
g_assert(old_invoice);
@@ -2495,12 +2496,13 @@
// Modify the date to today
timespecFromTime_t(&new_date, gnc_timet_get_today_start());
+ new_date_gdate = timespec_to_gdate(new_date);
gncInvoiceSetDateOpened(new_invoice, new_date);
// Also modify the date of all entries to today
//g_warning("We have %d entries", g_list_length(gncInvoiceGetEntries(new_invoice)));
g_list_foreach(gncInvoiceGetEntries(new_invoice),
- &set_gncEntry_date, &new_date);
+ &set_gncEntry_date, &new_date_gdate);
// Now open that newly created invoice in the "edit" window
iw = gnc_ui_invoice_edit (new_invoice);
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedger.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedger.c 2011-11-11 21:58:04 UTC (rev 21560)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedger.c 2011-11-11 21:58:21 UTC (rev 21561)
@@ -327,9 +327,9 @@
ledger->blank_entry_edited = FALSE;
{
- Timespec ts = { 0, 0 };
- ts.tv_sec = time (NULL);
- ledger->last_date_entered = timespecCanonicalDayTime (ts);
+ GDate *today = gnc_g_date_new_today();
+ ledger->last_date_entered = *today;
+ g_date_free(today);
}
{
@@ -554,7 +554,7 @@
* to understand why.
*/
if (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR)
- ledger->last_date_entered = gncInvoiceGetDateOpened (invoice);
+ ledger->last_date_entered = timespec_to_gdate(gncInvoiceGetDateOpened (invoice));
if (!ledger->query && invoice)
create_invoice_query (ledger);
@@ -927,7 +927,7 @@
new_entry = gncEntryCreate (ledger->book);
gncEntryCopy (entry, new_entry);
- gncEntrySetDate (new_entry, ledger->last_date_entered);
+ gncEntrySetDateGDate (new_entry, &ledger->last_date_entered);
/* We also must set a new DateEntered on the new entry
* because otherwise the ordering is not deterministic */
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c 2011-11-11 21:58:04 UTC (rev 21560)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerControl.c 2011-11-11 21:58:21 UTC (rev 21561)
@@ -67,7 +67,7 @@
{
if (ledger->blank_entry_edited)
{
- ledger->last_date_entered = gncEntryGetDate (entry);
+ ledger->last_date_entered = gncEntryGetDateGDate (entry);
ledger->blank_entry_guid = *guid_null ();
ledger->blank_entry_edited = FALSE;
blank_entry = NULL;
@@ -123,7 +123,7 @@
{
ledger->blank_entry_guid = *guid_null ();
blank_entry = NULL;
- ledger->last_date_entered = gncEntryGetDate (entry);
+ ledger->last_date_entered = gncEntryGetDateGDate (entry);
}
else
ledger->blank_entry_edited = TRUE;
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c 2011-11-11 21:58:04 UTC (rev 21560)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c 2011-11-11 21:58:21 UTC (rev 21561)
@@ -359,7 +359,7 @@
gnc_suspend_gui_refresh ();
blank_entry = gncEntryCreate (ledger->book);
- gncEntrySetDate (blank_entry, ledger->last_date_entered);
+ gncEntrySetDateGDate (blank_entry, &ledger->last_date_entered);
ledger->blank_entry_guid = *gncEntryGetGUID (blank_entry);
gnc_resume_gui_refresh ();
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c 2011-11-11 21:58:04 UTC (rev 21560)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerModel.c 2011-11-11 21:58:21 UTC (rev 21561)
@@ -1022,15 +1022,15 @@
ENTRY_DATE_CELL, TRUE))
{
BasicCell *cell;
- Timespec ts;
+ GDate date;
cell = gnc_table_layout_get_cell (ledger->table->layout, ENTRY_DATE_CELL);
/* commit any pending changes */
gnc_date_cell_commit ((DateCell *) cell);
- gnc_date_cell_get_date ((DateCell *) cell, &ts);
- gncEntrySetDate (entry, ts);
+ gnc_date_cell_get_date_gdate ((DateCell *) cell, &date);
+ gncEntrySetDateGDate (entry, &date);
}
if (gnc_table_layout_get_cell_changed (ledger->table->layout,
Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerP.h
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerP.h 2011-11-11 21:58:04 UTC (rev 21560)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerP.h 2011-11-11 21:58:21 UTC (rev 21561)
@@ -38,7 +38,7 @@
gboolean full_refresh; /* Is a full refresh ok? */
gint component_id; /* To register for events */
- Timespec last_date_entered;
+ GDate last_date_entered;
GncEntry * hint_entry; /* A Hint for where to display */
Modified: gnucash/trunk/src/plugins/bi_import/bi_import.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/bi_import.c 2011-11-11 21:58:04 UTC (rev 21560)
+++ gnucash/trunk/src/plugins/bi_import/bi_import.c 2011-11-11 21:58:21 UTC (rev 21561)
@@ -665,7 +665,11 @@
// add entry to invoice/bill
entry = gncEntryCreate (book);
qof_scan_date (date, &day, &month, &year);
- gncEntrySetDate (entry, gnc_dmy2timespec (day, month, year));
+ {
+ GDate *date = g_date_new_dmy(day, month, year);
+ gncEntrySetDateGDate (entry, date);
+ g_date_free (date);
+ }
timespecFromTime_t (&today, time (NULL)); // set today to the current date
gncEntrySetDateEntered (entry, today);
gncEntrySetDescription (entry, desc);
More information about the gnucash-changes
mailing list