Remove all timespecs from the register.

This commit is contained in:
John Ralls 2018-07-30 17:28:18 -07:00
parent 6846a68691
commit dd8732402f
6 changed files with 21 additions and 34 deletions

View File

@ -1036,15 +1036,15 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
return;
/* Special treatment if the equality doesn't hold if we access the
dates as timespec. See the comment in gncEntrySetDateGDate() for the
reason: Some code used the timespec at noon for the EntryDate, other
code used the timespec at the start of day. */
dates as time64. See the comment in gncEntrySetDateGDate() for the
reason: Some code used the time64 at noon for the EntryDate, other
code used the time64 at the start of day. */
t1 = gncEntryGetDate(current);
t2 = gncEntryGetDate(target);
if (t1 != t2)
{
/* Timespecs are not equal, even though the GDates were equal? Then
we set the GDates again. This will force the timespecs to be equal
/* times are not equal, even though the GDates were equal? Then
we set the GDates again. This will force the times to be equal
as well. */
gncEntrySetDateGDate(current, &d1);
gncEntrySetDateGDate(target, &d2);

View File

@ -186,13 +186,9 @@ static const char * get_date_entry (VirtualLocation virt_loc,
gpointer user_data)
{
GncEntryLedger *ledger = user_data;
GncEntry *entry;
Timespec ts = {0,0};
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
ts.tv_sec = gncEntryGetDate (entry);
return gnc_print_date (ts);
GncEntry *entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
time64 time = gncEntryGetDate (entry);
return qof_print_date(time);
}
static const char * get_desc_entry (VirtualLocation virt_loc,

View File

@ -487,7 +487,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
{
GDate *d = qof_book_get_autoreadonly_gdate(gnc_get_current_book());
// "d" is NULL if use_autoreadonly is FALSE
autoreadonly_time = d ? timespecToTime64(gdate_to_timespec(*d)) : 0;
autoreadonly_time = d ? gdate_to_time64 (*d) : 0;
g_date_free(d);
}

View File

@ -521,11 +521,11 @@ gnc_split_register_get_recn_tooltip (VirtualLocation virt_loc,
if (xaccSplitGetReconcile (split) == YREC)
{
Timespec ts = {0,0};
const char *str_rec_date;
xaccSplitGetDateReconciledTS (split, &ts);
str_rec_date = gnc_print_date (ts);
return g_strdup_printf (_("Reconciled on %s"), str_rec_date);
char datebuff[MAX_DATE_LENGTH + 1];
time64 time = xaccSplitGetDateReconciled (split);
memset (datebuff, 0, sizeof(datebuff));
qof_print_date_buff (datebuff, sizeof(datebuff), time);
return g_strdup_printf (_("Reconciled on %s"), datebuff);
}
else if (xaccSplitGetReconcile (split) == VREC)
{
@ -904,7 +904,6 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
SplitRegister *reg = user_data;
Transaction *trans;
Split *split;
Timespec ts = {0, 0};
gboolean is_current;
char type;
@ -941,10 +940,9 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
return NULL;
}
ts.tv_sec = xaccTransRetDateDue (trans);
//PWARN ("returning valid due_date entry");
return gnc_print_date (ts);
return qof_print_date (xaccTransRetDateDue (trans));
}
static const char *
@ -956,16 +954,12 @@ gnc_split_register_get_date_entry (VirtualLocation virt_loc,
SplitRegister *reg = user_data;
Transaction *trans;
Split *split;
Timespec ts = {0, 0};
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
trans = xaccSplitGetParent (split);
if (!trans)
return NULL;
ts.tv_sec = xaccTransRetDatePosted (trans);
return gnc_print_date (ts);
return qof_print_date (xaccTransRetDatePosted (trans));
}
static char *

View File

@ -2078,7 +2078,6 @@ record_price (SplitRegister *reg, Account *account, gnc_numeric value,
time64 time;
BasicCell *cell = gnc_table_layout_get_cell (reg->table->layout, DATE_CELL);
gboolean swap = FALSE;
Timespec ts;
/* Only record the price for account types that don't have a
* "rate" cell. They'll get handled later by
@ -2087,9 +2086,7 @@ record_price (SplitRegister *reg, Account *account, gnc_numeric value,
if (gnc_split_reg_has_rate_cell (reg->type))
return;
gnc_date_cell_get_date ((DateCell*)cell, &time);
ts.tv_sec = time;
ts.tv_nsec = 0;
price = gnc_pricedb_lookup_day (pricedb, comm, curr, ts);
price = gnc_pricedb_lookup_day_t64 (pricedb, comm, curr, time);
if (gnc_commodity_equiv (comm, gnc_price_get_currency (price)))
swap = TRUE;
@ -2116,7 +2113,7 @@ record_price (SplitRegister *reg, Account *account, gnc_numeric value,
value = gnc_numeric_convert(value, scu * COMMODITY_DENOM_MULT,
GNC_HOW_RND_ROUND_HALF_UP);
gnc_price_begin_edit (price);
gnc_price_set_time (price, ts);
gnc_price_set_time64 (price, time);
gnc_price_set_source (price, source);
gnc_price_set_typestr (price, PRICE_TYPE_TRN);
gnc_price_set_value (price, value);
@ -2131,7 +2128,7 @@ record_price (SplitRegister *reg, Account *account, gnc_numeric value,
gnc_price_begin_edit (price);
gnc_price_set_commodity (price, comm);
gnc_price_set_currency (price, curr);
gnc_price_set_time (price, ts);
gnc_price_set_time64 (price, time);
gnc_price_set_source (price, source);
gnc_price_set_typestr (price, PRICE_TYPE_TRN);
gnc_price_set_value (price, value);

View File

@ -120,13 +120,13 @@ void gnc_date_cell_set_value_secs (DateCell *cell, time64 secs);
*/
void gnc_date_cell_commit (DateCell *cell);
/** Set a Timespec to the value in the DateCell.
/** Set a time64 to the value in the DateCell.
* @param cell The DateCell
* @param time A time64* to which the function will write the time.
*/
void gnc_date_cell_get_date (DateCell *cell, time64 *time);
/** Timespec to the value in the DateCell.
/** Set a GDate to the value in the DateCell.
* @param cell The DateCell
* @param date A GDate* into which the functino will write the date.
*/