mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'remove-timespec' into maint
This commit is contained in:
commit
88597d0b64
@ -375,10 +375,10 @@ class GncPriceDB(GnuCashCoreClass):
|
||||
GncPriceDB.add_methods_with_prefix('gnc_pricedb_')
|
||||
PriceDB_dict = {
|
||||
'lookup_latest' : GncPrice,
|
||||
'lookup_nearest_in_time' : GncPrice,
|
||||
'lookup_latest_before' : GncPrice,
|
||||
'lookup_nearest_in_time64' : GncPrice,
|
||||
'lookup_latest_before_t64' : GncPrice,
|
||||
'convert_balance_latest_price' : GncNumeric,
|
||||
'convert_balance_nearest_price' : GncNumeric,
|
||||
'convert_balance_nearest_price_t64' : GncNumeric,
|
||||
}
|
||||
methods_return_instance(GncPriceDB,PriceDB_dict)
|
||||
GncPriceDB.get_prices = method_function_returns_instance_list(
|
||||
|
@ -282,7 +282,7 @@ gnc_dup_trans_dialog_gdate (GtkWidget * parent, GDate *gdate_p,
|
||||
time64 tmp_time;
|
||||
g_assert(gdate_p);
|
||||
|
||||
tmp_time = timespecToTime64(gdate_to_timespec(*gdate_p));
|
||||
tmp_time = gdate_to_time64 (*gdate_p);
|
||||
return gnc_dup_trans_dialog_internal(parent, NULL, TRUE, &tmp_time, gdate_p,
|
||||
num, out_num, NULL, NULL);
|
||||
}
|
||||
@ -293,7 +293,7 @@ gnc_dup_date_dialog (GtkWidget * parent, const char* title, GDate *gdate_p)
|
||||
time64 tmp_time;
|
||||
g_assert(gdate_p);
|
||||
|
||||
tmp_time = timespecToTime64(gdate_to_timespec(*gdate_p));
|
||||
tmp_time = gdate_to_time64(*gdate_p);
|
||||
return gnc_dup_trans_dialog_internal(parent, title, TRUE, &tmp_time, gdate_p,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ typedef struct
|
||||
GNCPriceDB *pricedb;
|
||||
gnc_commodity *from;
|
||||
gnc_commodity *to;
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
gboolean reverse;
|
||||
} PriceReq;
|
||||
|
||||
@ -243,7 +243,7 @@ price_request_from_xferData(PriceReq *pr, XferDialog *xd)
|
||||
pr->pricedb = xd->pricedb;
|
||||
pr->from = xd->from_commodity;
|
||||
pr->to = xd->to_commodity;
|
||||
pr->ts = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (xd->date_entry));
|
||||
pr->time = gnc_date_edit_get_date (GNC_DATE_EDIT (xd->date_entry));
|
||||
pr->reverse = FALSE;
|
||||
}
|
||||
|
||||
@ -261,12 +261,12 @@ lookup_price(PriceReq *pr, PriceDate pd)
|
||||
{
|
||||
default:
|
||||
case SAME_DAY:
|
||||
prc = gnc_pricedb_lookup_day (pr->pricedb, pr->from,
|
||||
pr->to, pr->ts);
|
||||
prc = gnc_pricedb_lookup_day_t64 (pr->pricedb, pr->from,
|
||||
pr->to, pr->time);
|
||||
break;
|
||||
case NEAREST:
|
||||
prc = gnc_pricedb_lookup_nearest_in_time (pr->pricedb, pr->from,
|
||||
pr->to, pr->ts);
|
||||
prc = gnc_pricedb_lookup_nearest_in_time64 (pr->pricedb, pr->from,
|
||||
pr->to, pr->time);
|
||||
break;
|
||||
case LATEST:
|
||||
prc = gnc_pricedb_lookup_latest (pr->pricedb, pr->from, pr->to);
|
||||
@ -1499,7 +1499,7 @@ check_edit(XferDialog *xferData)
|
||||
}
|
||||
|
||||
static void
|
||||
create_transaction(XferDialog *xferData, Timespec *ts,
|
||||
create_transaction(XferDialog *xferData, time64 time,
|
||||
Account *from_account, Account* to_account,
|
||||
gnc_numeric amount, gnc_numeric to_amount)
|
||||
{
|
||||
@ -1513,7 +1513,7 @@ create_transaction(XferDialog *xferData, Timespec *ts,
|
||||
xaccTransBeginEdit(trans);
|
||||
|
||||
xaccTransSetCurrency(trans, xferData->from_commodity);
|
||||
xaccTransSetDatePostedSecs(trans, ts->tv_sec);
|
||||
xaccTransSetDatePostedSecs(trans, time);
|
||||
|
||||
/* Trans-Num or Split-Action set with gnc_set_num_action below per book
|
||||
* option */
|
||||
@ -1601,7 +1601,7 @@ update_price(XferDialog *xferData, PriceReq *pr)
|
||||
return;
|
||||
}
|
||||
gnc_price_begin_edit (pr->price);
|
||||
gnc_price_set_time (pr->price, pr->ts);
|
||||
gnc_price_set_time64 (pr->price, pr->time);
|
||||
gnc_price_set_typestr(pr->price, xferData->price_type);
|
||||
gnc_price_set_value (pr->price, value);
|
||||
gnc_price_commit_edit (pr->price);
|
||||
@ -1613,7 +1613,7 @@ update_price(XferDialog *xferData, PriceReq *pr)
|
||||
}
|
||||
|
||||
static void
|
||||
new_price(XferDialog *xferData, Timespec ts)
|
||||
new_price(XferDialog *xferData, time64 time)
|
||||
{
|
||||
GNCPrice *price = NULL;
|
||||
gnc_commodity *from = xferData->from_commodity;
|
||||
@ -1637,7 +1637,7 @@ new_price(XferDialog *xferData, Timespec ts)
|
||||
gnc_price_begin_edit (price);
|
||||
gnc_price_set_commodity (price, from);
|
||||
gnc_price_set_currency (price, to);
|
||||
gnc_price_set_time (price, ts);
|
||||
gnc_price_set_time64 (price, time);
|
||||
gnc_price_set_source (price, xferData->price_source);
|
||||
gnc_price_set_typestr (price, xferData->price_type);
|
||||
gnc_price_set_value (price, value);
|
||||
@ -1649,7 +1649,7 @@ new_price(XferDialog *xferData, Timespec ts)
|
||||
}
|
||||
|
||||
static void
|
||||
create_price(XferDialog *xferData, Timespec ts)
|
||||
create_price(XferDialog *xferData, time64 time)
|
||||
{
|
||||
PriceReq pr;
|
||||
|
||||
@ -1664,7 +1664,7 @@ create_price(XferDialog *xferData, Timespec ts)
|
||||
update_price(xferData, &pr);
|
||||
return;
|
||||
}
|
||||
new_price (xferData, ts);
|
||||
new_price (xferData, time);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1674,7 +1674,7 @@ gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
Account *to_account;
|
||||
Account *from_account;
|
||||
gnc_numeric amount, to_amount;
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
GDate date;
|
||||
|
||||
g_return_if_fail (xferData != NULL);
|
||||
@ -1718,7 +1718,7 @@ gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
}
|
||||
g_date_clear (&date, 1);
|
||||
gnc_date_edit_get_gdate (GNC_DATE_EDIT (xferData->date_entry), &date);
|
||||
ts = gdate_to_timespec (date);
|
||||
time = gdate_to_time64 (date);
|
||||
|
||||
if (!gnc_commodity_equiv(xferData->from_commodity, xferData->to_commodity))
|
||||
{
|
||||
@ -1748,12 +1748,12 @@ gnc_xfer_dialog_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
||||
*(xferData->exch_rate) = gnc_numeric_abs(price_value);
|
||||
}
|
||||
else
|
||||
create_transaction (xferData, &ts, from_account, to_account,
|
||||
create_transaction (xferData, time, from_account, to_account,
|
||||
amount, to_amount);
|
||||
/* try to save this to the pricedb */
|
||||
if (xferData->pricedb && !gnc_commodity_equal (xferData->from_commodity,
|
||||
xferData->to_commodity))
|
||||
create_price(xferData, ts);
|
||||
create_price(xferData, time);
|
||||
/* Refresh everything */
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
|
@ -184,13 +184,13 @@ gnc_date_edit_popdown(GNCDateEdit *gde)
|
||||
static void
|
||||
day_selected (GtkCalendar *calendar, GNCDateEdit *gde)
|
||||
{
|
||||
Timespec t;
|
||||
time64 t;
|
||||
guint year, month, day;
|
||||
gde->in_selected_handler = TRUE;
|
||||
gtk_calendar_get_date (calendar, &year, &month, &day);
|
||||
/* GtkCalendar returns a 0-based month */
|
||||
t = gnc_dmy2timespec (day, month + 1, year);
|
||||
gnc_date_edit_set_time_ts (gde, t);
|
||||
t = gnc_dmy2time64 (day, month + 1, year);
|
||||
gnc_date_edit_set_time (gde, t);
|
||||
gde->in_selected_handler = FALSE;
|
||||
}
|
||||
|
||||
@ -809,12 +809,6 @@ gnc_date_edit_set_gdate (GNCDateEdit *gde, const GDate *date)
|
||||
gnc_date_edit_set_time(gde, t);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_date_edit_set_time_ts (GNCDateEdit *gde, Timespec the_time)
|
||||
{
|
||||
gnc_date_edit_set_time (gde, the_time.tv_sec);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnc_date_edit_set_popup_range:
|
||||
* @gde: The GNCDateEdit widget
|
||||
@ -1033,13 +1027,6 @@ gnc_date_edit_new (time64 the_time, int show_time, int use_24_format)
|
||||
| (use_24_format ? GNC_DATE_EDIT_24_HR : 0)));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gnc_date_edit_new_ts (Timespec the_time, int show_time, int use_24_format)
|
||||
{
|
||||
return gnc_date_edit_new (the_time.tv_sec, show_time, use_24_format);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create a new GncDateEdit widget from a glade file. The widget
|
||||
* generated is set to today's date, and will not show a time as part
|
||||
@ -1193,16 +1180,6 @@ gnc_date_edit_get_gdate (GNCDateEdit *gde, GDate *date)
|
||||
gnc_gdate_set_time64 (date, t);
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_date_edit_get_date_ts (GNCDateEdit *gde)
|
||||
{
|
||||
Timespec ts = { 0, 0 };
|
||||
|
||||
ts.tv_sec = gnc_date_edit_get_date (gde);
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnc_date_edit_get_date_end:
|
||||
* @gde: The GNCDateEdit widget
|
||||
@ -1224,16 +1201,6 @@ gnc_date_edit_get_date_end (GNCDateEdit *gde)
|
||||
return gnc_mktime (&tm);
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_date_edit_get_date_end_ts (GNCDateEdit *gde)
|
||||
{
|
||||
Timespec ts = { 0, 0 };
|
||||
|
||||
ts.tv_sec = gnc_date_edit_get_date_end (gde);
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnc_date_edit_set_flags:
|
||||
* @gde: The date editor widget whose flags should be changed.
|
||||
|
@ -93,8 +93,6 @@ GType gnc_date_edit_get_type (void);
|
||||
|
||||
GtkWidget *gnc_date_edit_new (time64 the_time,
|
||||
int show_time, int use_24_format);
|
||||
GtkWidget *gnc_date_edit_new_ts (Timespec the_time,
|
||||
int show_time, int use_24_format);
|
||||
|
||||
/**
|
||||
* Create a new GncDateEdit widget from a glade file. The widget
|
||||
@ -121,16 +119,13 @@ GtkWidget *gnc_date_edit_new_flags (time64 the_time,
|
||||
|
||||
void gnc_date_edit_set_gdate (GNCDateEdit *gde, const GDate *date);
|
||||
void gnc_date_edit_set_time (GNCDateEdit *gde, time64 the_time);
|
||||
void gnc_date_edit_set_time_ts (GNCDateEdit *gde, Timespec the_time);
|
||||
|
||||
void gnc_date_edit_set_popup_range (GNCDateEdit *gde,
|
||||
int low_hour, int up_hour);
|
||||
int low_hour, int up_hour);
|
||||
|
||||
void gnc_date_edit_get_gdate (GNCDateEdit *gde, GDate *date);
|
||||
time64 gnc_date_edit_get_date (GNCDateEdit *gde);
|
||||
Timespec gnc_date_edit_get_date_ts (GNCDateEdit *gde);
|
||||
time64 gnc_date_edit_get_date_end (GNCDateEdit *gde);
|
||||
Timespec gnc_date_edit_get_date_end_ts (GNCDateEdit *gde);
|
||||
time64 gnc_date_edit_get_date (GNCDateEdit *gde);
|
||||
time64 gnc_date_edit_get_date_end (GNCDateEdit *gde);
|
||||
|
||||
void gnc_date_edit_set_flags (GNCDateEdit *gde,
|
||||
GNCDateEditFlags flags);
|
||||
|
@ -1537,15 +1537,15 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
time1 = xaccTransRetDatePosted(current_trans);
|
||||
time2 = xaccTransRetDatePosted(target_trans);
|
||||
if (really_do_it && time1 != time2)
|
||||
{
|
||||
/* 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. */
|
||||
xaccTransSetDatePostedGDate(current_trans, d1);
|
||||
xaccTransSetDatePostedGDate(target_trans, d2);
|
||||
|
@ -679,6 +679,8 @@ gnc_tree_model_price_get_value (GtkTreeModel *tree_model,
|
||||
gnc_commodity_namespace *name_space;
|
||||
gnc_commodity *commodity;
|
||||
GNCPrice *price;
|
||||
char datebuff[MAX_DATE_LENGTH + 1];
|
||||
memset (datebuff, 0, sizeof(datebuff));
|
||||
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_PRICE (model));
|
||||
g_return_if_fail (iter != NULL);
|
||||
@ -767,8 +769,10 @@ gnc_tree_model_price_get_value (GtkTreeModel *tree_model,
|
||||
g_value_set_string (value, gnc_commodity_get_printname (commodity));
|
||||
break;
|
||||
case GNC_TREE_MODEL_PRICE_COL_DATE:
|
||||
qof_print_date_buff (datebuff, sizeof(datebuff),
|
||||
gnc_price_get_time64 (price));
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, gnc_print_date (gnc_price_get_time (price)));
|
||||
g_value_set_string (value, datebuff);
|
||||
break;
|
||||
case GNC_TREE_MODEL_PRICE_COL_SOURCE:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
|
@ -830,10 +830,11 @@ gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position
|
||||
{
|
||||
GncTreeModelSplitRegPrivate *priv;
|
||||
Transaction *trans;
|
||||
const gchar *date_text;
|
||||
char date_text[MAX_DATE_LENGTH + 1];
|
||||
const gchar *desc_text;
|
||||
GList *node;
|
||||
|
||||
memset (date_text, 0, sizeof(date_text));
|
||||
priv = model->priv;
|
||||
|
||||
node = g_list_nth (priv->full_tlist, position);
|
||||
@ -848,8 +849,8 @@ gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position
|
||||
return g_strconcat ("Blank Transaction", NULL);
|
||||
else
|
||||
{
|
||||
Timespec ts = {xaccTransRetDatePosted (trans), 0};
|
||||
date_text = gnc_print_date (ts);
|
||||
time64 t = xaccTransRetDatePosted (trans);
|
||||
qof_print_date_buff (date_text, sizeof(date_text), t);
|
||||
desc_text = xaccTransGetDescription (trans);
|
||||
model->current_trans = trans;
|
||||
return g_strconcat (date_text, "\n", desc_text, NULL);
|
||||
|
@ -219,7 +219,7 @@ static gint
|
||||
default_sort (GNCPrice *price_a, GNCPrice *price_b)
|
||||
{
|
||||
gnc_commodity *curr_a, *curr_b;
|
||||
Timespec ts_a, ts_b;
|
||||
time64 time_a, time_b;
|
||||
gint result;
|
||||
|
||||
/* Primary sort (i.e. commodity name) handled by the tree structure. */
|
||||
@ -237,9 +237,9 @@ default_sort (GNCPrice *price_a, GNCPrice *price_b)
|
||||
if (result != 0) return result;
|
||||
|
||||
/* tertiary sort: time */
|
||||
ts_a = gnc_price_get_time (price_a);
|
||||
ts_b = gnc_price_get_time (price_b);
|
||||
result = timespec_cmp (&ts_a, &ts_b);
|
||||
time_a = gnc_price_get_time64 (price_a);
|
||||
time_b = gnc_price_get_time64 (price_b);
|
||||
result = time_a < time_b ? -1 : time_a > time_b ? 1 : 0;
|
||||
if (result)
|
||||
/* Reverse the result to present the most recent quote first. */
|
||||
return -result;
|
||||
@ -270,16 +270,16 @@ sort_by_date (GtkTreeModel *f_model,
|
||||
gpointer user_data)
|
||||
{
|
||||
GNCPrice *price_a, *price_b;
|
||||
Timespec ts_a, ts_b;
|
||||
time64 time_a, time_b;
|
||||
gboolean result;
|
||||
|
||||
if (!get_prices (f_model, f_iter_a, f_iter_b, &price_a, &price_b))
|
||||
return sort_ns_or_cm (f_model, f_iter_a, f_iter_b);
|
||||
|
||||
/* sort by time first */
|
||||
ts_a = gnc_price_get_time (price_a);
|
||||
ts_b = gnc_price_get_time (price_b);
|
||||
result = timespec_cmp (&ts_a, &ts_b);
|
||||
time_a = gnc_price_get_time64 (price_a);
|
||||
time_b = gnc_price_get_time64 (price_b);
|
||||
result = time_a < time_b ? -1 : time_a > time_b ? 1 : 0;
|
||||
if (result)
|
||||
/* Reverse the result to present the most recent quote first. */
|
||||
return -result;
|
||||
|
@ -1394,6 +1394,7 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
|
||||
gnc_numeric num = gnc_numeric_zero();
|
||||
const gchar *s = "";
|
||||
const gchar *row_color;
|
||||
char datebuff[MAX_DATE_LENGTH + 1];
|
||||
RowDepth depth;
|
||||
gint *indices;
|
||||
Account *anchor = view->priv->anchor;
|
||||
@ -1462,6 +1463,7 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
|
||||
switch (viewcol) {
|
||||
case COL_DATE:
|
||||
/* Column is DATE */
|
||||
memset (datebuff, 0, sizeof(datebuff));
|
||||
if (is_split)
|
||||
g_object_set (cell, "cell-background", "white", (gchar*)NULL);
|
||||
|
||||
@ -1474,65 +1476,60 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
|
||||
show_extra_dates = TRUE;
|
||||
|
||||
if (is_trow1) {
|
||||
Timespec ts = {xaccTransRetDatePosted (trans),0};
|
||||
time64 t = xaccTransRetDatePosted (trans);
|
||||
//If the time returned by xaccTransGetDatePostedTS is 0 then assume it
|
||||
//is a new transaction and set the time to current time to show current
|
||||
//date on new transactions
|
||||
if (ts.tv_sec == 0)
|
||||
ts.tv_sec = gnc_time (NULL);
|
||||
s = gnc_print_date (ts);
|
||||
if (t == 0)
|
||||
t = gnc_time (NULL);
|
||||
qof_print_date_buff (datebuff, sizeof(datebuff), t);
|
||||
editable = TRUE;
|
||||
}
|
||||
else if (is_trow2 && show_extra_dates) {
|
||||
Timespec ts = {xaccTransRetDateEntered (trans),0};
|
||||
time64 t = xaccTransRetDateEntered (trans);
|
||||
g_object_set (cell, "cell-background", YELLOWCELL, (gchar*)NULL);
|
||||
//If the time returned by xaccTransGetDateEnteredTS is 0 then assume it
|
||||
//is a new transaction and set the time to current time to show current
|
||||
//date on new transactions
|
||||
if (ts.tv_sec == 0)
|
||||
ts.tv_sec = gnc_time (NULL);
|
||||
s = gnc_print_date (ts);
|
||||
if (t == 0)
|
||||
t = gnc_time (NULL);
|
||||
qof_print_date_buff (datebuff, sizeof(datebuff), t);
|
||||
editable = FALSE;
|
||||
}
|
||||
else if (is_split && show_extra_dates) {
|
||||
Timespec ts = {0,0};
|
||||
time64 t = 0;
|
||||
|
||||
if (xaccSplitGetReconcile (split) == YREC)
|
||||
{
|
||||
xaccSplitGetDateReconciledTS (split, &ts);
|
||||
t = xaccSplitGetDateReconciled (split);
|
||||
//If the time returned by xaccTransGetDateEnteredTS is 0 then assume it
|
||||
//is a new transaction and set the time to current time to show current
|
||||
//date on new transactions
|
||||
if (ts.tv_sec == 0)
|
||||
if (t == 0)
|
||||
{
|
||||
ts.tv_sec = gnc_time (NULL);
|
||||
t = gnc_time (NULL);
|
||||
//xaccSplitSetDateReconciledTS (split, ts.tv_sec);
|
||||
}//if
|
||||
s = gnc_print_date (ts);
|
||||
qof_print_date_buff (datebuff, sizeof(datebuff), 0);
|
||||
}
|
||||
else
|
||||
s = "";
|
||||
editable = FALSE;
|
||||
}
|
||||
else {
|
||||
s = "";
|
||||
editable = FALSE;
|
||||
}
|
||||
|
||||
/* Is this a template */
|
||||
if (is_template && is_trow1)
|
||||
{
|
||||
s = _(" Scheduled ");
|
||||
strncpy (datebuff, _(" Scheduled "), sizeof(datebuff));
|
||||
editable = FALSE;
|
||||
}
|
||||
else if (is_template && is_trow2 && show_extra_dates)
|
||||
{
|
||||
s = "";
|
||||
editable = FALSE;
|
||||
}
|
||||
else if (is_template && is_split && show_extra_dates)
|
||||
{
|
||||
s = "";
|
||||
editable = FALSE;
|
||||
}
|
||||
|
||||
@ -1540,11 +1537,12 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
|
||||
|
||||
/* This will remove the calander buttons if FALSE */
|
||||
g_object_set (cell, "use_buttons", view->priv->show_calendar_buttons, NULL );
|
||||
g_object_set (cell, "text", s, "editable", editable, NULL);
|
||||
g_object_set (cell, "text", datebuff, "editable", editable, NULL);
|
||||
break;
|
||||
|
||||
case COL_DUEDATE:
|
||||
/* Column is DUE DATE */
|
||||
memset (datebuff, 0, sizeof(datebuff));
|
||||
if (is_split)
|
||||
g_object_set (cell, "cell-background", "white", (gchar*)NULL);
|
||||
|
||||
@ -1552,18 +1550,17 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
|
||||
/* Only print the due date for invoice transactions */
|
||||
if (type == TXN_TYPE_INVOICE)
|
||||
{
|
||||
Timespec ts = {xaccTransRetDateDue (trans), 0};
|
||||
s = gnc_print_date (ts);
|
||||
time64 t = xaccTransRetDateDue (trans);
|
||||
qof_print_date_buff (datebuff, sizeof(datebuff), t);
|
||||
editable = FALSE;
|
||||
}
|
||||
else {
|
||||
s = "";
|
||||
editable = FALSE;
|
||||
}
|
||||
}
|
||||
editable = (read_only == TRUE) ? FALSE : editable;
|
||||
|
||||
g_object_set (cell, "text", s, "editable", editable, NULL);
|
||||
g_object_set (cell, "text", datebuff, "editable", editable, NULL);
|
||||
break;
|
||||
|
||||
case COL_NUMACT:
|
||||
|
@ -189,10 +189,11 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
case ACCT_TYPE_RECEIVABLE:
|
||||
end_amount = xaccAccountGetBalanceAsOfDate(account, options.end_date);
|
||||
end_amount_default_currency =
|
||||
gnc_pricedb_convert_balance_nearest_price (pricedb, end_amount,
|
||||
account_currency,
|
||||
to_curr,
|
||||
options.end_date);
|
||||
gnc_pricedb_convert_balance_nearest_price_t64 (pricedb,
|
||||
end_amount,
|
||||
account_currency,
|
||||
to_curr,
|
||||
options.end_date);
|
||||
|
||||
if (!non_currency || options.non_currency)
|
||||
{
|
||||
@ -224,17 +225,18 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
case ACCT_TYPE_EXPENSE:
|
||||
start_amount = xaccAccountGetBalanceAsOfDate(account, options.start_date);
|
||||
start_amount_default_currency =
|
||||
gnc_pricedb_convert_balance_nearest_price (pricedb,
|
||||
start_amount,
|
||||
account_currency,
|
||||
to_curr,
|
||||
options.start_date);
|
||||
gnc_pricedb_convert_balance_nearest_price_t64 (pricedb,
|
||||
start_amount,
|
||||
account_currency,
|
||||
to_curr,
|
||||
options.start_date);
|
||||
end_amount = xaccAccountGetBalanceAsOfDate(account, options.end_date);
|
||||
end_amount_default_currency =
|
||||
gnc_pricedb_convert_balance_nearest_price (pricedb, end_amount,
|
||||
account_currency,
|
||||
to_curr,
|
||||
options.end_date);
|
||||
gnc_pricedb_convert_balance_nearest_price_t64 (pricedb,
|
||||
end_amount,
|
||||
account_currency,
|
||||
to_curr,
|
||||
options.end_date);
|
||||
|
||||
if (!non_currency || options.non_currency)
|
||||
{
|
||||
|
@ -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. */
|
||||
|
@ -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);
|
||||
|
@ -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) = gnc_date_edit_get_date_ts (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) = gnc_date_edit_get_date_ts (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_ts (GNC_DATE_EDIT (ddc->date), *ts);
|
||||
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));
|
||||
@ -184,12 +184,12 @@ static void
|
||||
post_date_changed_cb (GNCDateEdit *gde, gpointer d)
|
||||
{
|
||||
DialogDateClose *ddc = d;
|
||||
Timespec post_date;
|
||||
Timespec due_date = {0,0};
|
||||
time64 post_date;
|
||||
time64 due_date = 0;
|
||||
|
||||
post_date = gnc_date_edit_get_date_ts (gde);
|
||||
due_date.tv_sec = gncBillTermComputeDueDate (ddc->terms, post_date.tv_sec);
|
||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), due_date);
|
||||
post_date = gnc_date_edit_get_date (gde);
|
||||
due_date = gncBillTermComputeDueDate (ddc->terms, post_date);
|
||||
gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->date), due_date);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -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_ts (GNC_DATE_EDIT (ddc->post_date), *post);
|
||||
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_ts (GNC_DATE_EDIT (ddc->date), *ddue);
|
||||
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_ts (GNC_DATE_EDIT (ddc->date), *date);
|
||||
gnc_date_edit_set_time (GNC_DATE_EDIT (ddc->date), *date);
|
||||
|
||||
/* Setup the account widget */
|
||||
fill_in_acct_info (ddc, FALSE);
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
@ -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,
|
||||
ts, 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 ();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -98,20 +98,20 @@ gnc_ab_set_account_uid(Account *a, guint32 uid)
|
||||
time64
|
||||
gnc_ab_get_account_trans_retrieval(const Account *a)
|
||||
{
|
||||
Timespec *t = NULL;
|
||||
Time64 *t = NULL;
|
||||
qof_instance_get (QOF_INSTANCE (a),
|
||||
"ab-trans-retrieval", &t,
|
||||
NULL);
|
||||
return t ? t->tv_sec : 0;
|
||||
return t ? t->t : 0;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_ab_set_account_trans_retrieval(Account *a, time64 time)
|
||||
{
|
||||
Timespec ts = {time, 0};
|
||||
Time64 t = {time};
|
||||
xaccAccountBeginEdit(a);
|
||||
qof_instance_set (QOF_INSTANCE (a),
|
||||
"ab-trans-retrieval", &ts,
|
||||
"ab-trans-retrieval", &t,
|
||||
NULL);
|
||||
xaccAccountCommitEdit(a);
|
||||
}
|
||||
|
@ -1137,7 +1137,8 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
|
||||
|
||||
while (!scm_is_null(possible_matches))
|
||||
{
|
||||
Timespec ts_send = {0,0};
|
||||
char datebuff[MAX_DATE_LENGTH + 1];
|
||||
memset(datebuff, 0, sizeof(datebuff));
|
||||
current_xtn = SCM_CAR(possible_matches);
|
||||
#define FUNC_NAME "xaccTransCountSplits"
|
||||
gnc_xtn = SWIG_MustGetPtr(SCM_CAR(current_xtn),
|
||||
@ -1159,11 +1160,12 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
|
||||
}
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
ts_send.tv_sec = xaccTransRetDatePosted(gnc_xtn);
|
||||
qof_print_date_buff(datebuff, sizeof(datebuff),
|
||||
xaccTransRetDatePosted(gnc_xtn));
|
||||
gtk_list_store_set
|
||||
(store, &iter,
|
||||
QIF_TRANS_COL_INDEX, rownum++,
|
||||
QIF_TRANS_COL_DATE, gnc_print_date(ts_send),
|
||||
QIF_TRANS_COL_DATE, datebuff,
|
||||
QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
|
||||
QIF_TRANS_COL_AMOUNT, amount_str,
|
||||
QIF_TRANS_COL_CHECKED, selected != SCM_BOOL_F,
|
||||
@ -3138,8 +3140,8 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
|
||||
while (!scm_is_null(duplicates))
|
||||
{
|
||||
time64 send_time = 0;
|
||||
char date_buf[MAX_DATE_LENGTH + 1];
|
||||
memset (date_buf, 0, sizeof(date_buf));
|
||||
char datebuff[MAX_DATE_LENGTH + 1];
|
||||
memset (datebuff, 0, sizeof(datebuff));
|
||||
current_xtn = SCM_CAAR(duplicates);
|
||||
#define FUNC_NAME "xaccTransCountSplits"
|
||||
gnc_xtn = SWIG_MustGetPtr(current_xtn,
|
||||
@ -3157,12 +3159,12 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
|
||||
}
|
||||
gtk_list_store_append(store, &iter);
|
||||
send_time = xaccTransRetDatePosted(gnc_xtn);
|
||||
qof_print_date_buff (date_buf, sizeof(date_buf), send_time);
|
||||
qof_print_date_buff (datebuff, sizeof(datebuff), send_time);
|
||||
gtk_list_store_set
|
||||
(store, &iter,
|
||||
QIF_TRANS_COL_INDEX, rownum++,
|
||||
QIF_TRANS_COL_DATE,
|
||||
date_buf,
|
||||
datebuff,
|
||||
QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
|
||||
QIF_TRANS_COL_AMOUNT, amount_str,
|
||||
-1);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -1204,36 +1204,6 @@ gnc_split_register_get_account_always (SplitRegister *reg,
|
||||
return gnc_split_register_get_account_by_name (reg, cell, name);
|
||||
}
|
||||
|
||||
#if 0 /* Not Used */
|
||||
static const char *
|
||||
gnc_split_register_get_cell_string (SplitRegister *reg, const char *cell_name)
|
||||
{
|
||||
BasicCell *cell;
|
||||
|
||||
cell = gnc_table_layout_get_cell (reg->table->layout, cell_name);
|
||||
if (!cell)
|
||||
return "";
|
||||
|
||||
return gnc_basic_cell_get_value (cell);
|
||||
}
|
||||
|
||||
static Timespec
|
||||
gnc_split_register_get_cell_date (SplitRegister *reg, const char *cell_name)
|
||||
{
|
||||
DateCell *cell;
|
||||
Timespec ts;
|
||||
|
||||
cell = (DateCell*) gnc_table_layout_get_cell (reg->table->layout, cell_name);
|
||||
|
||||
if (cell)
|
||||
gnc_date_cell_get_date (cell, &ts);
|
||||
else
|
||||
timespecFromTime64 (&ts, gnc_time (NULL));
|
||||
|
||||
return ts;
|
||||
}
|
||||
#endif /* Not Used */
|
||||
|
||||
/* Creates a transfer dialog and fills its values from register cells (if
|
||||
* available) or from the provided transaction and split.
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 *
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -712,7 +712,7 @@
|
||||
(begin ;; do so
|
||||
(set! missing-pricedb-entry? #f)
|
||||
(set! pricedb-lookup-price
|
||||
(let ((price (gnc-pricedb-lookup-nearest-in-time64
|
||||
(let ((price (gnc-pricedb-lookup-nearest-in-time-t64
|
||||
pricedb
|
||||
account-commodity
|
||||
USD-currency
|
||||
@ -725,9 +725,8 @@
|
||||
(gnc-price-get-value
|
||||
pricedb-lookup-price))
|
||||
(set! pricedb-lookup-price-time
|
||||
(gnc-price-get-time64
|
||||
pricedb-lookup-price))
|
||||
(gnc-pricedb-convert-balance-nearest-price
|
||||
(gnc-price-get-time64 pricedb-lookup-price))
|
||||
(gnc-pricedb-convert-balance-nearest-price-t64
|
||||
pricedb
|
||||
(if neg?
|
||||
(gnc-numeric-neg splt-rpt-amount)
|
||||
|
@ -794,7 +794,7 @@
|
||||
(gnc:exchange-if-same foreign domestic)
|
||||
(gnc:make-gnc-monetary
|
||||
domestic
|
||||
(gnc-pricedb-convert-balance-nearest-price
|
||||
(gnc-pricedb-convert-balance-nearest-price-t64
|
||||
(gnc-pricedb-get-db (gnc-get-current-book))
|
||||
(gnc:gnc-monetary-amount foreign)
|
||||
(gnc:gnc-monetary-commodity foreign)
|
||||
|
@ -138,7 +138,7 @@ setup_memory (Fixture* fixture, gconstpointer pData)
|
||||
frame->set ({"int64-val"}, new KvpValue (INT64_C (100)));
|
||||
frame->set ({"double-val"}, new KvpValue (3.14159));
|
||||
frame->set ({"numeric-val"}, new KvpValue (gnc_numeric_zero ()));
|
||||
frame->set ({"timespec-val"}, new KvpValue (timespec_now ()));
|
||||
frame->set ({"time-val"}, new KvpValue (gnc_time(nullptr)));
|
||||
frame->set ({"string-val"}, new KvpValue ("abcdefghijklmnop"));
|
||||
auto guid = qof_instance_get_guid (QOF_INSTANCE (acct1));
|
||||
frame->set ({"guid-val"}, new KvpValue (const_cast<GncGUID*> (guid_copy (
|
||||
|
@ -70,9 +70,9 @@ static void entry_set_bill (gpointer pObject, gpointer val);
|
||||
static EntryVec col_table
|
||||
({
|
||||
gnc_sql_make_table_entry<CT_GUID>("guid", 0, COL_NNUL | COL_PKEY, "guid"),
|
||||
gnc_sql_make_table_entry<CT_TIME64>("date", 0, COL_NNUL, ENTRY_DATE,
|
||||
gnc_sql_make_table_entry<CT_TIME>("date", 0, COL_NNUL, ENTRY_DATE,
|
||||
true),
|
||||
gnc_sql_make_table_entry<CT_TIME64>("date_entered", 0, 0,
|
||||
gnc_sql_make_table_entry<CT_TIME>("date_entered", 0, 0,
|
||||
ENTRY_DATE_ENTERED, true),
|
||||
gnc_sql_make_table_entry<CT_STRING>(
|
||||
"description", MAX_DESCRIPTION_LEN, 0, "description"),
|
||||
|
@ -67,9 +67,9 @@ static EntryVec col_table
|
||||
gnc_sql_make_table_entry<CT_GUID>("guid", 0, COL_NNUL | COL_PKEY, "guid"),
|
||||
gnc_sql_make_table_entry<CT_STRING>("id", MAX_ID_LEN, COL_NNUL, INVOICE_ID,
|
||||
true),
|
||||
gnc_sql_make_table_entry<CT_TIME64>("date_opened", 0, 0, INVOICE_OPENED,
|
||||
gnc_sql_make_table_entry<CT_TIME>("date_opened", 0, 0, INVOICE_OPENED,
|
||||
true),
|
||||
gnc_sql_make_table_entry<CT_TIME64>("date_posted", 0, 0, INVOICE_POSTED,
|
||||
gnc_sql_make_table_entry<CT_TIME>("date_posted", 0, 0, INVOICE_POSTED,
|
||||
true),
|
||||
gnc_sql_make_table_entry<CT_STRING>("notes", MAX_NOTES_LEN, COL_NNUL,
|
||||
"notes"),
|
||||
|
@ -66,9 +66,9 @@ static EntryVec col_table
|
||||
gnc_sql_make_table_entry<CT_STRING>(
|
||||
"reference", MAX_REFERENCE_LEN, COL_NNUL, "reference"),
|
||||
gnc_sql_make_table_entry<CT_BOOLEAN>("active", 0, COL_NNUL, "order"),
|
||||
gnc_sql_make_table_entry<CT_TIMESPEC>("date_opened", 0, COL_NNUL,
|
||||
gnc_sql_make_table_entry<CT_TIME>("date_opened", 0, COL_NNUL,
|
||||
"date-opened"),
|
||||
gnc_sql_make_table_entry<CT_TIMESPEC>("date_closed", 0, COL_NNUL,
|
||||
gnc_sql_make_table_entry<CT_TIME>("date_closed", 0, COL_NNUL,
|
||||
"date-closed"),
|
||||
gnc_sql_make_table_entry<CT_OWNERREF>("owner", 0, COL_NNUL,
|
||||
ORDER_OWNER, true),
|
||||
|
@ -63,7 +63,7 @@ static const EntryVec col_table
|
||||
"commodity"),
|
||||
gnc_sql_make_table_entry<CT_COMMODITYREF>("currency_guid", 0, COL_NNUL,
|
||||
"currency"),
|
||||
gnc_sql_make_table_entry<CT_TIMESPEC>("date", 0, COL_NNUL, "date"),
|
||||
gnc_sql_make_table_entry<CT_TIME>("date", 0, COL_NNUL, "date"),
|
||||
gnc_sql_make_table_entry<CT_STRING>("source", PRICE_MAX_SOURCE_LEN, 0,
|
||||
"source"),
|
||||
gnc_sql_make_table_entry<CT_STRING>("type", PRICE_MAX_TYPE_LEN, 0, "type"),
|
||||
|
@ -90,8 +90,8 @@ static gpointer get_string_val (gpointer pObject);
|
||||
static void set_string_val (gpointer pObject, gpointer pValue);
|
||||
static gpointer get_double_val (gpointer pObject);
|
||||
static void set_double_val (gpointer pObject, gpointer pValue);
|
||||
static Timespec get_timespec_val (gpointer pObject);
|
||||
static void set_timespec_val (gpointer pObject, Timespec *ts);
|
||||
static time64 get_time_val (gpointer pObject);
|
||||
static void set_time_val (gpointer pObject, time64 t);
|
||||
static gpointer get_guid_val (gpointer pObject);
|
||||
static void set_guid_val (gpointer pObject, gpointer pValue);
|
||||
static gnc_numeric get_numeric_val (gpointer pObject);
|
||||
@ -112,7 +112,7 @@ enum
|
||||
int64_val_col,
|
||||
string_val_col,
|
||||
double_val_col,
|
||||
timespec_val_col,
|
||||
time_val_col,
|
||||
guid_val_col,
|
||||
numeric_val_col,
|
||||
gdate_val_col
|
||||
@ -140,9 +140,9 @@ static const EntryVec col_table
|
||||
gnc_sql_make_table_entry<CT_DOUBLE>("double_val", 0, 0,
|
||||
(QofAccessFunc)get_double_val,
|
||||
set_double_val),
|
||||
gnc_sql_make_table_entry<CT_TIMESPEC>("timespec_val", 0, 0,
|
||||
(QofAccessFunc)get_timespec_val,
|
||||
(QofSetterFunc)set_timespec_val),
|
||||
gnc_sql_make_table_entry<CT_TIME>("time_val", 0, 0,
|
||||
(QofAccessFunc)get_time_val,
|
||||
(QofSetterFunc)set_time_val),
|
||||
gnc_sql_make_table_entry<CT_GUID>("guid_val", 0, 0,
|
||||
(QofAccessFunc)get_guid_val,
|
||||
set_guid_val),
|
||||
@ -390,27 +390,28 @@ set_double_val (gpointer pObject, gpointer pValue)
|
||||
set_slot_from_value (pInfo, value);
|
||||
}
|
||||
|
||||
static Timespec
|
||||
get_timespec_val (gpointer pObject)
|
||||
static time64
|
||||
get_time_val (gpointer pObject)
|
||||
{
|
||||
slot_info_t* pInfo = (slot_info_t*)pObject;
|
||||
|
||||
g_return_val_if_fail (pObject != NULL, gnc_dmy2timespec (1, 1, 1970));
|
||||
g_return_val_if_fail (pObject != NULL, 0);
|
||||
|
||||
//if( kvp_value_get_type( pInfo->pKvpValue ) == KvpValue::Type::TIMESPEC ) {
|
||||
return pInfo->pKvpValue->get<Timespec> ();
|
||||
//if( kvp_value_get_type( pInfo->pKvpValue ) == KvpValue::Type::TIME64 ) {
|
||||
auto t = pInfo->pKvpValue->get<Time64> ();
|
||||
return t.t;
|
||||
}
|
||||
|
||||
static void
|
||||
set_timespec_val (gpointer pObject, Timespec *ts)
|
||||
set_time_val (gpointer pObject, time64 time)
|
||||
{
|
||||
slot_info_t* pInfo = (slot_info_t*)pObject;
|
||||
KvpValue* value = NULL;
|
||||
|
||||
Time64 t{time};
|
||||
g_return_if_fail (pObject != NULL);
|
||||
|
||||
if (pInfo->value_type != KvpValue::Type::TIMESPEC) return;
|
||||
value = new KvpValue {*ts};
|
||||
if (pInfo->value_type != KvpValue::Type::TIME64) return;
|
||||
value = new KvpValue {t};
|
||||
set_slot_from_value (pInfo, value);
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ protected:
|
||||
bool m_loading; /**< We are performing an initial load */
|
||||
bool m_in_query; /**< We are processing a query */
|
||||
bool m_is_pristine_db; /**< Are we saving to a new pristine db? */
|
||||
const char* m_timespec_format = nullptr; /**< Server-specific date-time string format */
|
||||
const char* m_time_format = nullptr; /**< Server-specific date-time string format */
|
||||
VersionVec m_versions; /**< Version number for each table */
|
||||
private:
|
||||
bool write_account_tree(Account*);
|
||||
|
@ -367,111 +367,18 @@ GncSqlColumnTableEntryImpl<CT_GUID>::add_to_query(QofIdTypeConst obj_name,
|
||||
}
|
||||
}
|
||||
/* ----------------------------------------------------------------- */
|
||||
typedef Timespec (*TimespecAccessFunc) (const gpointer);
|
||||
typedef void (*TimespecSetterFunc) (const gpointer, Timespec*);
|
||||
|
||||
#define TIMESPEC_COL_SIZE (4+3+3+3+3+3)
|
||||
|
||||
template<> void
|
||||
GncSqlColumnTableEntryImpl<CT_TIMESPEC>::load (const GncSqlBackend* sql_be,
|
||||
GncSqlRow& row,
|
||||
QofIdTypeConst obj_name,
|
||||
gpointer pObject) const noexcept
|
||||
{
|
||||
|
||||
Timespec ts = {0, 0};
|
||||
gboolean isOK = FALSE;
|
||||
|
||||
|
||||
g_return_if_fail (pObject != NULL);
|
||||
g_return_if_fail (m_gobj_param_name != nullptr || get_setter(obj_name) != nullptr);
|
||||
|
||||
try
|
||||
{
|
||||
auto val = row.get_time64_at_col(m_col_name);
|
||||
timespecFromTime64 (&ts, val);
|
||||
}
|
||||
catch (std::invalid_argument&)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto val = row.get_string_at_col(m_col_name);
|
||||
GncDateTime time(val);
|
||||
ts.tv_sec = static_cast<time64>(time);
|
||||
}
|
||||
catch (const std::invalid_argument& err)
|
||||
{
|
||||
if (strcmp(err.what(), "Column empty.") != 0)
|
||||
{
|
||||
auto val = row.get_string_at_col(m_col_name);
|
||||
PWARN("An invalid date %s was found in your database."
|
||||
"It has been set to 1 January 1970.", val.c_str());
|
||||
}
|
||||
ts.tv_sec = 0;
|
||||
}
|
||||
}
|
||||
set_parameter(pObject, &ts,
|
||||
reinterpret_cast<TimespecSetterFunc>(get_setter(obj_name)),
|
||||
m_gobj_param_name);
|
||||
}
|
||||
|
||||
template<> void
|
||||
GncSqlColumnTableEntryImpl<CT_TIMESPEC>::add_to_table(ColVec& vec) const noexcept
|
||||
{
|
||||
GncSqlColumnInfo info{*this, BCT_DATETIME, TIMESPEC_COL_SIZE, FALSE};
|
||||
vec.emplace_back(std::move(info));
|
||||
}
|
||||
|
||||
template<> void
|
||||
GncSqlColumnTableEntryImpl<CT_TIMESPEC>::add_to_query(QofIdTypeConst obj_name,
|
||||
const gpointer pObject,
|
||||
PairVec& vec) const noexcept
|
||||
{
|
||||
TimespecAccessFunc ts_getter;
|
||||
Timespec ts;
|
||||
/* Can't use get_row_value_from_object because g_object_get returns a
|
||||
* Timespec* and the getter returns a Timespec. Will be fixed by the
|
||||
* replacement of timespecs with time64s.
|
||||
*/
|
||||
g_return_if_fail (obj_name != NULL);
|
||||
g_return_if_fail (pObject != NULL);
|
||||
|
||||
if (m_gobj_param_name != NULL)
|
||||
{
|
||||
Timespec* pts;
|
||||
g_object_get (pObject, m_gobj_param_name, &pts, NULL);
|
||||
ts = *pts;
|
||||
}
|
||||
else
|
||||
{
|
||||
ts_getter = (TimespecAccessFunc)get_getter (obj_name);
|
||||
g_return_if_fail (ts_getter != NULL);
|
||||
ts = (*ts_getter) (pObject);
|
||||
}
|
||||
if (ts.tv_sec > MINTIME && ts.tv_sec < MAXTIME)
|
||||
{
|
||||
GncDateTime time(ts.tv_sec);
|
||||
vec.emplace_back (std::make_pair (std::string{m_col_name},
|
||||
time.format_zulu ("'%Y-%m-%d %H:%M:%S'")));
|
||||
}
|
||||
else
|
||||
{
|
||||
vec.emplace_back (std::make_pair (std::string{m_col_name},
|
||||
"NULL"));
|
||||
}
|
||||
}
|
||||
/* ----------------------------------------------------------------- */
|
||||
typedef time64 (*Time64AccessFunc) (const gpointer);
|
||||
typedef void (*Time64SetterFunc) (const gpointer, time64);
|
||||
constexpr int TIME_COL_SIZE = 4 + 3 + 3 + 3 + 3 + 3;
|
||||
|
||||
template<> void
|
||||
GncSqlColumnTableEntryImpl<CT_TIME64>::load (const GncSqlBackend* sql_be,
|
||||
GncSqlColumnTableEntryImpl<CT_TIME>::load (const GncSqlBackend* sql_be,
|
||||
GncSqlRow& row,
|
||||
QofIdTypeConst obj_name,
|
||||
gpointer pObject)
|
||||
const noexcept
|
||||
{
|
||||
time64 t;
|
||||
time64 t{0};
|
||||
g_return_if_fail (m_gobj_param_name != nullptr || get_setter(obj_name) != nullptr);
|
||||
try
|
||||
{
|
||||
@ -485,33 +392,62 @@ GncSqlColumnTableEntryImpl<CT_TIME64>::load (const GncSqlBackend* sql_be,
|
||||
GncDateTime time(val);
|
||||
t = static_cast<time64>(time);
|
||||
}
|
||||
catch (std::invalid_argument&)
|
||||
catch (const std::invalid_argument& err)
|
||||
{
|
||||
return;
|
||||
if (strcmp(err.what(), "Column empty.") != 0)
|
||||
{
|
||||
auto val = row.get_string_at_col (m_col_name);
|
||||
PWARN("An invalid date %s was found in your database."
|
||||
"It has been set to 1 January 1970.", val.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
set_parameter(pObject, t,
|
||||
reinterpret_cast<Time64SetterFunc>(get_setter(obj_name)),
|
||||
m_gobj_param_name);
|
||||
if (m_gobj_param_name != nullptr)
|
||||
{
|
||||
Time64 t64{t};
|
||||
set_parameter(pObject, &t64, m_gobj_param_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_parameter(pObject, t,
|
||||
reinterpret_cast<Time64SetterFunc>(get_setter(obj_name)),
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
template<> void
|
||||
GncSqlColumnTableEntryImpl<CT_TIME64>::add_to_table(ColVec& vec) const noexcept
|
||||
GncSqlColumnTableEntryImpl<CT_TIME>::add_to_table(ColVec& vec) const noexcept
|
||||
{
|
||||
|
||||
GncSqlColumnInfo info{*this, BCT_DATETIME, TIMESPEC_COL_SIZE, FALSE};
|
||||
GncSqlColumnInfo info{*this, BCT_DATETIME, TIME_COL_SIZE, FALSE};
|
||||
vec.emplace_back(std::move(info));
|
||||
}
|
||||
|
||||
template<> void
|
||||
GncSqlColumnTableEntryImpl<CT_TIME64>::add_to_query(QofIdTypeConst obj_name,
|
||||
GncSqlColumnTableEntryImpl<CT_TIME>::add_to_query(QofIdTypeConst obj_name,
|
||||
const gpointer pObject,
|
||||
PairVec& vec) const noexcept
|
||||
{
|
||||
auto t = get_row_value_from_object<time64>(obj_name, pObject);
|
||||
if (t > MINTIME && t < MAXTIME)
|
||||
/* We still can't use get_row_value_from_object because while g_value could
|
||||
* contentedly store a time64 in an int64, KVP wouldn't be able to tell them
|
||||
* apart, so we have the struct Time64 hack, see engine/gnc-date.c.
|
||||
*/
|
||||
time64 t64;
|
||||
if (m_gobj_param_name != nullptr)
|
||||
{
|
||||
GncDateTime time(t);
|
||||
Time64* t;
|
||||
g_object_get (pObject, m_gobj_param_name, &t, nullptr);
|
||||
t64 = t->t;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto getter = (Time64AccessFunc)get_getter (obj_name);
|
||||
g_return_if_fail(getter != nullptr);
|
||||
t64 = (*getter)(pObject);
|
||||
}
|
||||
if (t64 > MINTIME && t64 < MAXTIME)
|
||||
{
|
||||
GncDateTime time(t64);
|
||||
vec.emplace_back (std::make_pair (std::string{m_col_name},
|
||||
time.format_zulu ("'%Y-%m-%d %H:%M:%S'")));
|
||||
}
|
||||
@ -539,7 +475,7 @@ GncSqlColumnTableEntryImpl<CT_GDATE>::load (const GncSqlBackend* sql_be,
|
||||
g_date_clear (&date, 1);
|
||||
try
|
||||
{
|
||||
/* timespec_to_gdate applies the tz, and gdates are saved
|
||||
/* time64_to_gdate applies the tz, and gdates are saved
|
||||
* as ymd, so we don't want that.
|
||||
*/
|
||||
auto time = row.get_time64_at_col(m_col_name);
|
||||
@ -667,7 +603,7 @@ GncSqlColumnTableEntryImpl<CT_NUMERIC>::add_to_query(QofIdTypeConst obj_name,
|
||||
const gpointer pObject,
|
||||
PairVec& vec) const noexcept
|
||||
{
|
||||
/* We can't use get_row_value_from_object for the same reason as Timespec. */
|
||||
/* We can't use get_row_value_from_object for the same reason as time64. */
|
||||
NumericGetterFunc getter;
|
||||
gnc_numeric n;
|
||||
|
||||
|
@ -71,8 +71,7 @@ enum GncSqlObjectType
|
||||
CT_GUID,
|
||||
CT_INT,
|
||||
CT_INT64,
|
||||
CT_TIMESPEC,
|
||||
CT_TIME64,
|
||||
CT_TIME,
|
||||
CT_GDATE,
|
||||
CT_NUMERIC,
|
||||
CT_DOUBLE,
|
||||
|
@ -90,8 +90,8 @@ static const EntryVec tx_col_table
|
||||
gnc_sql_make_table_entry<CT_COMMODITYREF>("currency_guid", 0, COL_NNUL,
|
||||
"currency"),
|
||||
gnc_sql_make_table_entry<CT_STRING>("num", TX_MAX_NUM_LEN, COL_NNUL, "num"),
|
||||
gnc_sql_make_table_entry<CT_TIMESPEC>("post_date", 0, 0, "post-date"),
|
||||
gnc_sql_make_table_entry<CT_TIMESPEC>("enter_date", 0, 0, "enter-date"),
|
||||
gnc_sql_make_table_entry<CT_TIME>("post_date", 0, 0, "post-date"),
|
||||
gnc_sql_make_table_entry<CT_TIME>("enter_date", 0, 0, "enter-date"),
|
||||
gnc_sql_make_table_entry<CT_STRING>("description", TX_MAX_DESCRIPTION_LEN,
|
||||
0, "description"),
|
||||
};
|
||||
@ -116,7 +116,7 @@ static const EntryVec split_col_table
|
||||
gnc_sql_make_table_entry<CT_STRING>("reconcile_state", 1, COL_NNUL,
|
||||
(QofAccessFunc)get_split_reconcile_state,
|
||||
set_split_reconcile_state),
|
||||
gnc_sql_make_table_entry<CT_TIMESPEC>("reconcile_date", 0, 0,
|
||||
gnc_sql_make_table_entry<CT_TIME>("reconcile_date", 0, 0,
|
||||
"reconcile-date"),
|
||||
gnc_sql_make_table_entry<CT_NUMERIC>("value", 0, COL_NNUL, "value"),
|
||||
gnc_sql_make_table_entry<CT_NUMERIC>("quantity", 0, COL_NNUL, "amount"),
|
||||
@ -127,7 +127,7 @@ static const EntryVec split_col_table
|
||||
|
||||
static const EntryVec post_date_col_table
|
||||
{
|
||||
gnc_sql_make_table_entry<CT_TIMESPEC>("post_date", 0, 0, "post-date"),
|
||||
gnc_sql_make_table_entry<CT_TIME>("post_date", 0, 0, "post-date"),
|
||||
};
|
||||
|
||||
static const EntryVec account_guid_col_table
|
||||
|
@ -597,30 +597,6 @@ gnc_sql_add_objectref_guid_col_info_to_list (,// 1
|
||||
test_gnc_sql_add_objectref_guid_col_info_to_list (Fixture *fixture, gconstpointer pData)
|
||||
{
|
||||
}*/
|
||||
/* load_timespec
|
||||
static void
|
||||
load_timespec (const GncSqlBackend* sql_be, GncSqlRow& row,// 2
|
||||
*/
|
||||
/* static void
|
||||
test_load_timespec (Fixture *fixture, gconstpointer pData)
|
||||
{
|
||||
}*/
|
||||
/* add_timespec_col_info_to_list
|
||||
static void
|
||||
add_timespec_col_info_to_list (const GncSqlBackend* sql_be, const GncSqlColumnTableEntry& table_row,// 2
|
||||
*/
|
||||
/* static void
|
||||
test_add_timespec_col_info_to_list (Fixture *fixture, gconstpointer pData)
|
||||
{
|
||||
}*/
|
||||
/* add_value_timespec_to_vec
|
||||
static void
|
||||
add_gvalue_timespec_to_slist (const GncSqlBackend* sql_be, QofIdTypeConst obj_name,// 2
|
||||
*/
|
||||
/* static void
|
||||
test_add_value_timespec_to_vec (Fixture *fixture, gconstpointer pData)
|
||||
{
|
||||
}*/
|
||||
/* load_date
|
||||
static void
|
||||
load_date (const GncSqlBackend* sql_be, GncSqlRow& row,// 2
|
||||
@ -915,9 +891,6 @@ test_suite_gnc_backend_sql (void)
|
||||
// GNC_TEST_ADD (suitename, "add value guid to vec", Fixture, nullptr, test_add_value_guid_to_vec, teardown);
|
||||
// GNC_TEST_ADD (suitename, "gnc sql add gvalue objectref guid to slist", Fixture, nullptr, test_gnc_sql_add_objectref_guid_to_vec, teardown);
|
||||
// GNC_TEST_ADD (suitename, "gnc sql add objectref guid col info to list", Fixture, nullptr, test_gnc_sql_add_objectref_guid_col_info_to_list, teardown);
|
||||
// GNC_TEST_ADD (suitename, "load timespec", Fixture, nullptr, test_load_timespec, teardown);
|
||||
// GNC_TEST_ADD (suitename, "add timespec col info to list", Fixture, nullptr, test_add_timespec_col_info_to_list, teardown);
|
||||
// GNC_TEST_ADD (suitename, "add value timespec to vec", Fixture, nullptr, test_add_value_timespec_to_vec, teardown);
|
||||
// GNC_TEST_ADD (suitename, "load date", Fixture, nullptr, test_load_date, teardown);
|
||||
// GNC_TEST_ADD (suitename, "add date col info to list", Fixture, nullptr, test_add_date_col_info_to_list, teardown);
|
||||
// GNC_TEST_ADD (suitename, "add value date to vec", Fixture, nullptr, test_add_value_date_to_vec, teardown);
|
||||
|
@ -115,8 +115,7 @@ price_parse_xml_sub_node (GNCPrice* p, xmlNodePtr sub_node, QofBook* book)
|
||||
{
|
||||
time64 time = dom_tree_to_time64 (sub_node);
|
||||
if (!dom_tree_valid_time64 (time, sub_node->name)) time = 0;
|
||||
Timespec ts {time, 0};
|
||||
gnc_price_set_time (p, ts);
|
||||
gnc_price_set_time64 (p, time);
|
||||
}
|
||||
else if (g_strcmp0 ("price:source", (char*)sub_node->name) == 0)
|
||||
{
|
||||
@ -416,7 +415,7 @@ gnc_price_to_dom_tree (const xmlChar* tag, GNCPrice* price)
|
||||
xmlNodePtr tmpnode;
|
||||
gnc_commodity* commodity;
|
||||
gnc_commodity* currency;
|
||||
Timespec timesp;
|
||||
time64 time;
|
||||
gnc_numeric value;
|
||||
|
||||
if (! (tag && price)) return NULL;
|
||||
@ -438,8 +437,8 @@ gnc_price_to_dom_tree (const xmlChar* tag, GNCPrice* price)
|
||||
tmpnode = commodity_ref_to_dom_tree ("price:currency", currency);
|
||||
if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
|
||||
|
||||
timesp = gnc_price_get_time (price);
|
||||
tmpnode = time64_to_dom_tree ("price:time", timesp.tv_sec);
|
||||
time = gnc_price_get_time64 (price);
|
||||
tmpnode = time64_to_dom_tree ("price:time", time);
|
||||
if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
|
||||
|
||||
sourcestr = gnc_price_get_source_string (price);
|
||||
|
@ -63,15 +63,6 @@ add_time64 (xmlNodePtr node, const gchar * tag, time64 time, gboolean always)
|
||||
xmlAddChild (node, time64_to_dom_tree (tag, time));
|
||||
}
|
||||
|
||||
static void
|
||||
add_timespec (xmlNodePtr node, const gchar* tag, Timespec tms, gboolean always)
|
||||
{
|
||||
if (always || tms.tv_sec)
|
||||
{
|
||||
xmlAddChild (node, time64_to_dom_tree (tag, tms.tv_sec));
|
||||
}
|
||||
}
|
||||
|
||||
static xmlNodePtr
|
||||
split_to_dom_tree (const gchar* tag, Split* spl)
|
||||
{
|
||||
@ -113,8 +104,8 @@ split_to_dom_tree (const gchar* tag, Split* spl)
|
||||
BAD_CAST tmp);
|
||||
}
|
||||
|
||||
add_timespec (ret, "split:reconcile-date",
|
||||
xaccSplitRetDateReconciledTS (spl), FALSE);
|
||||
add_time64 (ret, "split:reconcile-date",
|
||||
xaccSplitGetDateReconciled (spl), FALSE);
|
||||
|
||||
add_gnc_num (ret, "split:value", xaccSplitGetValue (spl));
|
||||
|
||||
@ -445,12 +436,11 @@ set_tran_time64 (xmlNodePtr node, Transaction * trn,
|
||||
|
||||
static inline gboolean
|
||||
set_tran_date (xmlNodePtr node, Transaction* trn,
|
||||
void (*func) (Transaction* trn, const Timespec* tm))
|
||||
void (*func) (Transaction* trn, const time64 tm))
|
||||
{
|
||||
time64 time = dom_tree_to_time64 (node);
|
||||
if (!dom_tree_valid_time64 (time, node->name)) time = 0;
|
||||
Timespec ts {time, 0};
|
||||
func (trn, &ts);
|
||||
func (trn, time);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -2961,8 +2961,7 @@ price_parse_xml_sub_node (GNCPrice* p, xmlNodePtr sub_node, QofBook* book)
|
||||
{
|
||||
time64 time = dom_tree_to_time64 (sub_node);
|
||||
if (!dom_tree_valid_time64 (time, sub_node->name)) time = 0;
|
||||
Timespec ts = {time, 0};
|
||||
gnc_price_set_time (p, ts);
|
||||
gnc_price_set_time64 (p, time);
|
||||
}
|
||||
else if (g_strcmp0 ("price:source", (char*)sub_node->name) == 0)
|
||||
{
|
||||
|
@ -131,18 +131,12 @@ commodity_ref_to_dom_tree (const char* tag, const gnc_commodity* c)
|
||||
return ret;
|
||||
}
|
||||
|
||||
char*
|
||||
time64_to_string (time64 time)
|
||||
{
|
||||
return gnc_print_time64 (time, TIMESPEC_TIME_FORMAT " %q");
|
||||
}
|
||||
|
||||
xmlNodePtr
|
||||
time64_to_dom_tree (const char* tag, const time64 time)
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
g_return_val_if_fail (time != INT64_MAX, NULL);
|
||||
auto date_str = time64_to_string (time);
|
||||
auto date_str = gnc_print_time64 (time, "%Y-%m-%d %H:%M:%S %q");
|
||||
if (!date_str)
|
||||
return NULL;
|
||||
ret = xmlNewNode (NULL, BAD_CAST tag);
|
||||
@ -237,7 +231,7 @@ add_kvp_value_node (xmlNodePtr node, const gchar* tag, KvpValue* val)
|
||||
g_free (newstr);
|
||||
break;
|
||||
}
|
||||
case KvpValue::Type::TIMESPEC:
|
||||
case KvpValue::Type::TIME64:
|
||||
val_node = NULL;
|
||||
break;
|
||||
case KvpValue::Type::GDATE:
|
||||
@ -277,10 +271,13 @@ add_kvp_value_node (xmlNodePtr node, const gchar* tag, KvpValue* val)
|
||||
add_text_to_node (val_node, "guid", guidstr);
|
||||
break;
|
||||
}
|
||||
case KvpValue::Type::TIMESPEC:
|
||||
/* Note: The type attribute must remain 'timespec' to maintain
|
||||
* compatibility.
|
||||
*/
|
||||
case KvpValue::Type::TIME64:
|
||||
{
|
||||
auto ts = val->get<Timespec> ();
|
||||
val_node = time64_to_dom_tree (tag, ts.tv_sec);
|
||||
auto t = val->get<Time64> ();
|
||||
val_node = time64_to_dom_tree (tag, t.t);
|
||||
xmlSetProp (val_node, BAD_CAST "type", BAD_CAST "timespec");
|
||||
xmlAddChild (node, val_node);
|
||||
break;
|
||||
|
@ -41,7 +41,6 @@ xmlNodePtr boolean_to_dom_tree (const char* tag, gboolean val);
|
||||
xmlNodePtr guid_to_dom_tree (const char* tag, const GncGUID* gid);
|
||||
xmlNodePtr commodity_ref_to_dom_tree (const char* tag, const gnc_commodity* c);
|
||||
xmlNodePtr time64_to_dom_tree (const char* tag, time64);
|
||||
gchar* time64_to_string (time64);
|
||||
xmlNodePtr gdate_to_dom_tree (const char* tag, const GDate* spec);
|
||||
xmlNodePtr gnc_numeric_to_dom_tree (const char* tag, const gnc_numeric* num);
|
||||
xmlNodePtr qof_instance_slots_to_dom_tree (const char* tag,
|
||||
|
@ -235,7 +235,8 @@ dom_tree_to_guid_kvp_value (xmlNodePtr node)
|
||||
static KvpValue*
|
||||
dom_tree_to_time64_kvp_value (xmlNodePtr node)
|
||||
{
|
||||
return new KvpValue {Timespec {dom_tree_to_time64 (node), 0}};
|
||||
Time64 t{dom_tree_to_time64 (node)};
|
||||
return new KvpValue {t};
|
||||
}
|
||||
|
||||
static KvpValue*
|
||||
@ -347,6 +348,8 @@ struct kvp_val_converter
|
||||
const gchar* tag;
|
||||
KvpValue* (*converter) (xmlNodePtr node);
|
||||
};
|
||||
/* Note: The type attribute must remain 'timespec' to maintain compatibility.
|
||||
*/
|
||||
|
||||
struct kvp_val_converter val_converters[] =
|
||||
{
|
||||
@ -523,12 +526,6 @@ dom_tree_to_gnc_numeric (xmlNodePtr node)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static time64
|
||||
time_parse_failure ()
|
||||
{
|
||||
return INT64_MAX;
|
||||
}
|
||||
|
||||
|
||||
time64
|
||||
dom_tree_to_time64 (xmlNodePtr node)
|
||||
@ -536,17 +533,16 @@ dom_tree_to_time64 (xmlNodePtr node)
|
||||
/* Turn something like this
|
||||
|
||||
<date-posted>
|
||||
<s>Mon, 05 Jun 2000 23:16:19 -0500</s>
|
||||
<ns>658864000</ns>
|
||||
<ts:date>Mon, 05 Jun 2000 23:16:19 -0500</ts:date>
|
||||
</date-posted>
|
||||
|
||||
into a time64. If this returns FALSE, the effects on *ts are
|
||||
undefined. The XML is valid if it has at least one of <s> or <ns>
|
||||
and no more than one of each. Order is irrelevant. */
|
||||
into a time64, returning INT64_MAX that we're using to flag an erroneous
|
||||
date if there's a problem. Only one ts:date element is permitted for any
|
||||
date attribute.
|
||||
*/
|
||||
|
||||
time64 ret {INT64_MAX};
|
||||
gboolean seen_s = FALSE;
|
||||
gboolean seen_ns = FALSE;
|
||||
gboolean seen = FALSE;
|
||||
xmlNodePtr n;
|
||||
|
||||
for (n = node->xmlChildrenNode; n; n = n->next)
|
||||
@ -559,39 +555,35 @@ dom_tree_to_time64 (xmlNodePtr node)
|
||||
case XML_ELEMENT_NODE:
|
||||
if (g_strcmp0 ("ts:date", (char*)n->name) == 0)
|
||||
{
|
||||
if (seen_s)
|
||||
if (seen)
|
||||
{
|
||||
return time_parse_failure ();
|
||||
return INT64_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar* content = dom_tree_to_text (n);
|
||||
if (!content)
|
||||
{
|
||||
return time_parse_failure ();
|
||||
return INT64_MAX;
|
||||
}
|
||||
|
||||
if (!string_to_time64 (content, &ret))
|
||||
{
|
||||
g_free (content);
|
||||
return time_parse_failure ();
|
||||
}
|
||||
ret = gnc_iso8601_to_time64_gmt (content);
|
||||
g_free (content);
|
||||
seen_s = TRUE;
|
||||
seen = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PERR ("unexpected sub-node.");
|
||||
return time_parse_failure ();
|
||||
return INT64_MAX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!seen_s)
|
||||
if (!seen)
|
||||
{
|
||||
PERR ("no ts:date node found.");
|
||||
return time_parse_failure ();
|
||||
return INT64_MAX;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -346,7 +346,7 @@ simple_chars_only_parser_new (sixtp_end_handler end_handler)
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* generic timespec handler.
|
||||
/* generic timespec handler for XML Version 1 files.
|
||||
|
||||
A collection of node functions intended to parse a sub-node set
|
||||
that looks like this:
|
||||
@ -362,13 +362,6 @@ simple_chars_only_parser_new (sixtp_end_handler end_handler)
|
||||
all goes well, returns the time64 as the result.
|
||||
*/
|
||||
|
||||
gboolean
|
||||
string_to_time64 (const gchar* str, time64* time)
|
||||
{
|
||||
*time = gnc_iso8601_to_time64_gmt (str);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* Top level timespec node:
|
||||
|
||||
input: user end handler *
|
||||
@ -436,17 +429,17 @@ generic_timespec_secs_end_handler (gpointer data_for_children,
|
||||
{
|
||||
gchar* txt = NULL;
|
||||
Time64ParseInfo* info = (Time64ParseInfo*) parent_data;
|
||||
gboolean ok;
|
||||
|
||||
g_return_val_if_fail (parent_data, FALSE);
|
||||
|
||||
txt = concatenate_child_result_chars (data_from_children);
|
||||
g_return_val_if_fail (txt, FALSE);
|
||||
|
||||
ok = string_to_time64 (txt, & info->time);
|
||||
info->time = gnc_iso8601_to_time64_gmt (txt);
|
||||
g_free (txt);
|
||||
|
||||
g_return_val_if_fail (ok, FALSE);
|
||||
// gnc_iso8601_to_time64_gmt returns INT64_MAX on failure.
|
||||
g_return_val_if_fail (info->time < INT64_MAX, FALSE);
|
||||
|
||||
info->s_block_count++;
|
||||
return (TRUE);
|
||||
|
@ -35,10 +35,6 @@ typedef struct
|
||||
guint s_block_count;
|
||||
} Time64ParseInfo;
|
||||
|
||||
#define TIMESPEC_TIME_FORMAT "%Y-%m-%d %H:%M:%S"
|
||||
#define TIMESPEC_PARSE_TIME_FORMAT "%Y-%m-%d %H:%M:%S"
|
||||
#define TIMESPEC_SEC_FORMAT_MAX 256
|
||||
|
||||
gboolean isspace_str (const gchar* str, int nomorethan);
|
||||
|
||||
gboolean allow_and_ignore_only_whitespace (GSList* sibling_data,
|
||||
@ -84,8 +80,6 @@ gboolean generic_return_chars_end_handler (gpointer data_for_children,
|
||||
|
||||
sixtp* simple_chars_only_parser_new (sixtp_end_handler end_handler);
|
||||
|
||||
gboolean string_to_time64 (const gchar* str, time64* ts);
|
||||
|
||||
gboolean generic_timespec_start_handler (GSList* sibling_data,
|
||||
gpointer parent_data,
|
||||
gpointer global_data,
|
||||
|
@ -57,7 +57,7 @@ set(test_backend_xml_module_SOURCES
|
||||
)
|
||||
|
||||
set_local_dist(test_backend_xml_DIST_local CMakeLists.txt grab-types.pl
|
||||
README test-date-converting.cpp test-dom-converters1.cpp
|
||||
README test-dom-converters1.cpp
|
||||
test-dom-parser1.cpp test-file-stuff.cpp test-file-stuff.h test-kvp-frames.cpp
|
||||
test-load-backend.cpp test-load-example-account.cpp test-load-xml2.cpp
|
||||
test-save-in-lang.cpp test-string-converters.cpp test-xml2-is-file.cpp
|
||||
@ -65,7 +65,6 @@ set_local_dist(test_backend_xml_DIST_local CMakeLists.txt grab-types.pl
|
||||
test-xml-pricedb.cpp test-xml-transaction.cpp)
|
||||
set(test_backend_xml_DIST ${test_backend_xml_DIST_local} ${test_backend_xml_test_files_DIST} PARENT_SCOPE)
|
||||
|
||||
add_xml_test(test-date-converting "${test_backend_xml_base_SOURCES};test-date-converting.cpp")
|
||||
add_xml_test(test-dom-converters1 "${test_backend_xml_base_SOURCES};test-dom-converters1.cpp")
|
||||
add_xml_test(test-kvp-frames "${test_backend_xml_base_SOURCES};test-kvp-frames.cpp")
|
||||
add_xml_test(test-load-backend test-load-backend.cpp)
|
||||
|
@ -1,67 +0,0 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
extern "C"
|
||||
{
|
||||
#include <config.h>
|
||||
|
||||
#include "test-engine-stuff.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
}
|
||||
|
||||
#include "test-file-stuff.h"
|
||||
#include "sixtp-utils.h"
|
||||
#include "sixtp-dom-generators.h"
|
||||
#include "test-stuff.h"
|
||||
|
||||
#define GNC_V2_STRING "gnc-v2"
|
||||
const gchar* gnc_v2_xml_version_string = GNC_V2_STRING;
|
||||
|
||||
int
|
||||
main (int argc, char** argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 20; i++)
|
||||
{
|
||||
time64 spec2;
|
||||
auto spec1 = get_random_time ();
|
||||
auto sec_str = time64_to_string (spec1);
|
||||
if (!string_to_time64 (sec_str, &spec2))
|
||||
{
|
||||
failure_args ("string_to_timespec_secs", __FILE__, __LINE__,
|
||||
"string is %s", sec_str);
|
||||
}
|
||||
else if (spec1 != spec2)
|
||||
{
|
||||
failure_args ("timespec_secs", __FILE__, __LINE__,
|
||||
"not equal ints are %" G_GINT64_FORMAT
|
||||
" and %" G_GINT64_FORMAT "\n",
|
||||
spec1, spec2);
|
||||
}
|
||||
else
|
||||
{
|
||||
success ("timespec");
|
||||
}
|
||||
g_free (sec_str);
|
||||
}
|
||||
print_test_results ();
|
||||
exit (get_rv ());
|
||||
}
|
@ -138,7 +138,7 @@ test_dom_tree_to_time64 (void)
|
||||
time64 test_spec2 = dom_tree_to_time64 (test_node);
|
||||
if (!dom_tree_valid_time64 (test_spec2, (const xmlChar*)"test-spec"))
|
||||
{
|
||||
failure_args ("dom_tree_to_timespec",
|
||||
failure_args ("dom_tree_to_time64",
|
||||
__FILE__, __LINE__, "NULL return");
|
||||
printf ("Node looks like:\n");
|
||||
xmlElemDump (stdout, NULL, test_node);
|
||||
|
@ -1551,7 +1551,7 @@ Return the commodity of @var{p}.
|
||||
Return the currency of @var{p}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun Timespec gnc_price_get_time (GNCPrice * @var{p})
|
||||
@deftypefun time64 gnc_price_get_time64 (GNCPrice * @var{p})
|
||||
Return the time of @var{p}.
|
||||
@end deftypefun
|
||||
|
||||
@ -1596,7 +1596,7 @@ Set the commodity of @var{p} to @var{c}.
|
||||
Set the currency of @var{p} to @var{c}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void gnc_price_set_time (GNCPrice * @var{p}, Timespec @var{t})
|
||||
@deftypefun void gnc_price_set_time64 (GNCPrice * @var{p}, time64 @var{t})
|
||||
Set the time of @var{p} to @var{t}.
|
||||
@end deftypefun
|
||||
|
||||
|
@ -995,7 +995,7 @@ gnc_account_class_init (AccountClass *klass)
|
||||
"AQBanking Last Transaction Retrieval",
|
||||
"The time of the last transaction retrieval for this "
|
||||
"account.",
|
||||
GNC_TYPE_TIMESPEC,
|
||||
GNC_TYPE_TIME64,
|
||||
static_cast<GParamFlags>(G_PARAM_READWRITE)));
|
||||
|
||||
}
|
||||
@ -3311,19 +3311,6 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
|
||||
priv = GET_PRIVATE(acc);
|
||||
balance = priv->balance;
|
||||
|
||||
/* Since transaction post times are stored as a Timespec,
|
||||
* convert date into a Timespec as well rather than converting
|
||||
* each transaction's Timespec into a time64.
|
||||
*
|
||||
* FIXME: CAS: I think this comment is a bogus justification for
|
||||
* using xaccTransGetDatePostedTS. There's no benefit to using
|
||||
* Timespec when the input argument is time64, and it's hard to
|
||||
* imagine that casting long long to long and comparing two longs is
|
||||
* worse than comparing two long longs every time. IMO,
|
||||
* xaccAccountGetPresentBalance gets this right, and its algorithm
|
||||
* should be used here.
|
||||
*/
|
||||
|
||||
lp = priv->splits;
|
||||
while ( lp && !found )
|
||||
{
|
||||
@ -3432,7 +3419,6 @@ xaccAccountConvertBalanceToCurrencyAsOfDate(const Account *acc, /* for book */
|
||||
{
|
||||
QofBook *book;
|
||||
GNCPriceDB *pdb;
|
||||
Timespec ts;
|
||||
|
||||
if (gnc_numeric_zero_p (balance) ||
|
||||
gnc_commodity_equiv (balance_currency, new_currency))
|
||||
@ -3441,7 +3427,7 @@ xaccAccountConvertBalanceToCurrencyAsOfDate(const Account *acc, /* for book */
|
||||
book = gnc_account_get_book (acc);
|
||||
pdb = gnc_pricedb_get_db (book);
|
||||
|
||||
balance = gnc_pricedb_convert_balance_nearest_price(
|
||||
balance = gnc_pricedb_convert_balance_nearest_price_t64(
|
||||
pdb, balance, balance_currency, new_currency, date);
|
||||
|
||||
return balance;
|
||||
|
@ -10,6 +10,7 @@ set(engine_noinst_HEADERS
|
||||
SX-book.h
|
||||
SX-ttinfo.h
|
||||
TransactionP.h
|
||||
engine-deprecated.h
|
||||
gnc-backend-prov.hpp
|
||||
gnc-date-p.h
|
||||
gnc-hooks-scm.h
|
||||
@ -149,6 +150,7 @@ set (engine_SOURCES
|
||||
Transaction.c
|
||||
cap-gains.c
|
||||
cashobjects.c
|
||||
engine-deprecated.c
|
||||
gnc-aqbanking-templates.cpp
|
||||
gnc-budget.c
|
||||
gnc-commodity.c
|
||||
@ -304,6 +306,7 @@ set(engine_EXTRA_DIST
|
||||
design.txt
|
||||
engine.i
|
||||
engine-common.i
|
||||
engine-deprecated.i
|
||||
extensions.txt
|
||||
iso-4217-currencies.xml
|
||||
iso-currencies-to-c.xsl
|
||||
|
@ -391,23 +391,23 @@ time64
|
||||
recurrenceGetPeriodTime(const Recurrence *r, guint period_num, gboolean end)
|
||||
{
|
||||
GDate date;
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
recurrenceNthInstance(r, period_num + (end ? 1 : 0), &date);
|
||||
if (end)
|
||||
{
|
||||
g_date_subtract_days(&date, 1);
|
||||
ts = gnc_dmy2timespec_end (g_date_get_day(&date),
|
||||
time = gnc_dmy2time64_end (g_date_get_day(&date),
|
||||
g_date_get_month(&date),
|
||||
g_date_get_year (&date));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ts = gnc_dmy2timespec (g_date_get_day(&date),
|
||||
time = gnc_dmy2time64 (g_date_get_day(&date),
|
||||
g_date_get_month(&date),
|
||||
g_date_get_year (&date));
|
||||
}
|
||||
return timespecToTime64(ts);
|
||||
return time;
|
||||
}
|
||||
|
||||
gnc_numeric
|
||||
|
@ -115,8 +115,7 @@ gnc_split_init(Split* split)
|
||||
split->amount = gnc_numeric_zero();
|
||||
split->value = gnc_numeric_zero();
|
||||
|
||||
split->date_reconciled.tv_sec = 0;
|
||||
split->date_reconciled.tv_nsec = 0;
|
||||
split->date_reconciled = 0;
|
||||
|
||||
split->balance = gnc_numeric_zero();
|
||||
split->cleared_balance = gnc_numeric_zero();
|
||||
@ -151,6 +150,7 @@ gnc_split_get_property(GObject *object,
|
||||
{
|
||||
Split *split;
|
||||
gchar *key;
|
||||
Time64 t;
|
||||
|
||||
g_return_if_fail(GNC_IS_SPLIT(object));
|
||||
|
||||
@ -170,7 +170,8 @@ gnc_split_get_property(GObject *object,
|
||||
g_value_set_boxed(value, &split->amount);
|
||||
break;
|
||||
case PROP_RECONCILE_DATE:
|
||||
g_value_set_boxed(value, &split->date_reconciled);
|
||||
t.t = split->date_reconciled;
|
||||
g_value_set_boxed(value, &t);
|
||||
break;
|
||||
case PROP_TX:
|
||||
g_value_take_object(value, split->parent);
|
||||
@ -223,7 +224,7 @@ gnc_split_set_property(GObject *object,
|
||||
Split *split;
|
||||
gnc_numeric* number;
|
||||
gchar *key;
|
||||
|
||||
Time64 *t;
|
||||
g_return_if_fail(GNC_IS_SPLIT(object));
|
||||
|
||||
split = GNC_SPLIT(object);
|
||||
@ -247,7 +248,8 @@ gnc_split_set_property(GObject *object,
|
||||
xaccSplitSetAmount(split, *number);
|
||||
break;
|
||||
case PROP_RECONCILE_DATE:
|
||||
xaccSplitSetDateReconciledTS(split, g_value_get_boxed(value));
|
||||
t = g_value_get_boxed(value);
|
||||
xaccSplitSetDateReconciledSecs(split, t->t);
|
||||
break;
|
||||
case PROP_TX:
|
||||
xaccSplitSetParent(split, g_value_get_object(value));
|
||||
@ -353,7 +355,7 @@ gnc_split_class_init(SplitClass* klass)
|
||||
g_param_spec_boxed("reconcile-date",
|
||||
"Reconcile Date",
|
||||
"The date this split was reconciled.",
|
||||
GNC_TYPE_TIMESPEC,
|
||||
GNC_TYPE_TIME64,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
@ -506,8 +508,7 @@ xaccSplitReinit(Split * split)
|
||||
split->amount = gnc_numeric_zero();
|
||||
split->value = gnc_numeric_zero();
|
||||
|
||||
split->date_reconciled.tv_sec = 0;
|
||||
split->date_reconciled.tv_nsec = 0;
|
||||
split->date_reconciled = 0;
|
||||
|
||||
split->balance = gnc_numeric_zero();
|
||||
split->cleared_balance = gnc_numeric_zero();
|
||||
@ -653,6 +654,9 @@ xaccSplitCopyOnto(const Split *from_split, Split *to_split)
|
||||
void
|
||||
xaccSplitDump (const Split *split, const char *tag)
|
||||
{
|
||||
char datebuff[MAX_DATE_LENGTH + 1];
|
||||
memset (datebuff, 0, sizeof(datebuff));
|
||||
qof_print_date_buff (datebuff, sizeof(datebuff), split->date_reconciled);
|
||||
printf(" %s Split %p", tag, split);
|
||||
printf(" Book: %p\n", qof_instance_get_book(split));
|
||||
printf(" Account: %p (%s)\n", split->acc,
|
||||
@ -667,8 +671,8 @@ xaccSplitDump (const Split *split, const char *tag)
|
||||
printf(" Memo: %s\n", split->memo ? split->memo : "(null)");
|
||||
printf(" Action: %s\n", split->action ? split->action : "(null)");
|
||||
printf(" KVP Data: %s\n", qof_instance_kvp_as_string (QOF_INSTANCE (split)));
|
||||
printf(" Recncld: %c (date %s)\n", split->reconciled,
|
||||
gnc_print_date(split->date_reconciled));
|
||||
printf(" Recncld: %c (date %s)\n", split->reconciled, datebuff);
|
||||
|
||||
printf(" Value: %s\n", gnc_numeric_to_string(split->value));
|
||||
printf(" Amount: %s\n", gnc_numeric_to_string(split->amount));
|
||||
printf(" Balance: %s\n", gnc_numeric_to_string(split->balance));
|
||||
@ -707,8 +711,7 @@ xaccFreeSplit (Split *split)
|
||||
split->acc = NULL;
|
||||
split->orig_acc = NULL;
|
||||
|
||||
split->date_reconciled.tv_sec = 0;
|
||||
split->date_reconciled.tv_nsec = 0;
|
||||
split->date_reconciled = 0;
|
||||
G_OBJECT_CLASS (QOF_INSTANCE_GET_CLASS (&split->inst))->dispose(G_OBJECT (split));
|
||||
// Is this right?
|
||||
if (split->gains_split) split->gains_split->gains_split = NULL;
|
||||
@ -817,7 +820,7 @@ xaccSplitEqual(const Split *sa, const Split *sb,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (timespec_cmp(&(sa->date_reconciled), &(sb->date_reconciled)))
|
||||
if (sa->date_reconciled != sb->date_reconciled)
|
||||
{
|
||||
PINFO ("reconciled date differs");
|
||||
return FALSE;
|
||||
@ -1513,7 +1516,10 @@ xaccSplitOrder (const Split *sa, const Split *sb)
|
||||
if (comp > 0) return +1;
|
||||
|
||||
/* if dates differ, return */
|
||||
DATE_CMP(sa, sb, date_reconciled);
|
||||
if (sa->date_reconciled < sb->date_reconciled)
|
||||
return -1;
|
||||
else if (sa->date_reconciled > sb->date_reconciled)
|
||||
return 1;
|
||||
|
||||
/* else, sort on guid - keeps sort stable. */
|
||||
retval = qof_instance_guid_compare(sa, sb);
|
||||
@ -1771,44 +1777,18 @@ xaccSplitSetDateReconciledSecs (Split *split, time64 secs)
|
||||
if (!split) return;
|
||||
xaccTransBeginEdit (split->parent);
|
||||
|
||||
split->date_reconciled.tv_sec = secs;
|
||||
split->date_reconciled.tv_nsec = 0;
|
||||
split->date_reconciled = secs;
|
||||
qof_instance_set_dirty(QOF_INSTANCE(split));
|
||||
xaccTransCommitEdit(split->parent);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
xaccSplitSetDateReconciledTS (Split *split, Timespec *ts)
|
||||
{
|
||||
if (!split || !ts) return;
|
||||
xaccTransBeginEdit (split->parent);
|
||||
|
||||
split->date_reconciled = *ts;
|
||||
qof_instance_set_dirty(QOF_INSTANCE(split));
|
||||
xaccTransCommitEdit(split->parent);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
xaccSplitGetDateReconciledTS (const Split * split, Timespec *ts)
|
||||
{
|
||||
if (!split || !ts) return;
|
||||
*ts = (split->date_reconciled);
|
||||
}
|
||||
|
||||
Timespec
|
||||
xaccSplitRetDateReconciledTS (const Split * split)
|
||||
{
|
||||
Timespec ts = {0, 0};
|
||||
return split ? split->date_reconciled : ts;
|
||||
}
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
time64
|
||||
xaccSplitGetDateReconciled (const Split * split)
|
||||
{
|
||||
return split ? split->date_reconciled.tv_sec : 0;
|
||||
return split ? split->date_reconciled : 0;
|
||||
}
|
||||
/*################## Added for Reg2 #################*/
|
||||
|
||||
@ -2003,7 +1983,7 @@ xaccSplitAddPeerSplit (Split *split, const Split *other_split,
|
||||
guid = qof_instance_get_guid (QOF_INSTANCE (other_split));
|
||||
xaccTransBeginEdit (split->parent);
|
||||
qof_instance_kvp_add_guid (QOF_INSTANCE (split), "lot-split",
|
||||
timespec_now(), "peer_guid", guid_copy(guid));
|
||||
gnc_time(NULL), "peer_guid", guid_copy(guid));
|
||||
mark_split (split);
|
||||
qof_instance_set_dirty (QOF_INSTANCE (split));
|
||||
xaccTransCommitEdit (split->parent);
|
||||
|
@ -191,15 +191,6 @@ char xaccSplitGetReconcile (const Split *split);
|
||||
/** Set the date on which this split was reconciled by specifying the
|
||||
* time as time64. */
|
||||
void xaccSplitSetDateReconciledSecs (Split *split, time64 time);
|
||||
/** Set the date on which this split was reconciled by specifying the
|
||||
* time as Timespec. Caller still owns *ts! */
|
||||
void xaccSplitSetDateReconciledTS (Split *split, Timespec *ts);
|
||||
/** Get the date on which this split was reconciled by having it
|
||||
* written into the Timespec that 'ts' is pointing to. */
|
||||
void xaccSplitGetDateReconciledTS (const Split *split,
|
||||
Timespec *ts);
|
||||
/** Returns the date (as Timespec) on which this split was reconciled. */
|
||||
Timespec xaccSplitRetDateReconciledTS (const Split *split);
|
||||
|
||||
/*################## Added for Reg2 #################*/
|
||||
/** Retrieve the date when the Split was reconciled. */
|
||||
|
@ -93,8 +93,8 @@ struct split_s
|
||||
*/
|
||||
char * action; /* Buy, Sell, Div, etc. */
|
||||
|
||||
Timespec date_reconciled; /* date split was reconciled */
|
||||
char reconciled; /* The reconciled field */
|
||||
time64 date_reconciled; /* date split was reconciled */
|
||||
char reconciled; /* The reconciled field */
|
||||
|
||||
/* gains is a flag used to track the relationship between
|
||||
* capital-gains splits. Depending on its value, this flag indicates
|
||||
@ -202,28 +202,6 @@ void DxaccSplitSetShareAmount (Split *split, double amount);
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#define DATE_CMP(aaa,bbb,field) { \
|
||||
/* if dates differ, return */ \
|
||||
if ( (aaa->field.tv_sec) < \
|
||||
(bbb->field.tv_sec)) { \
|
||||
return -1; \
|
||||
} else \
|
||||
if ( (aaa->field.tv_sec) > \
|
||||
(bbb->field.tv_sec)) { \
|
||||
return +1; \
|
||||
} \
|
||||
\
|
||||
/* else, seconds match. check nanoseconds */ \
|
||||
if ( (aaa->field.tv_nsec) < \
|
||||
(bbb->field.tv_nsec)) { \
|
||||
return -1; \
|
||||
} else \
|
||||
if ( (aaa->field.tv_nsec) > \
|
||||
(bbb->field.tv_nsec)) { \
|
||||
return +1; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define CHECK_GAINS_STATUS(s) \
|
||||
if (GAINS_STATUS_UNKNOWN == s->gains) xaccSplitDetermineGainStatus(s);
|
||||
|
||||
|
@ -244,7 +244,7 @@ xaccTransWriteLog (Transaction *trans, char flag)
|
||||
|
||||
for (node = trans->splits; node; node = node->next)
|
||||
{
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
Split *split = node->data;
|
||||
const char * accname = "";
|
||||
char acc_guid_str[GUID_ENCODING_LENGTH + 1];
|
||||
@ -261,8 +261,7 @@ xaccTransWriteLog (Transaction *trans, char flag)
|
||||
acc_guid_str[0] = '\0';
|
||||
}
|
||||
|
||||
timespecFromTime64(&ts, split->date_reconciled.tv_sec);
|
||||
gnc_timespec_to_iso8601_buff (ts, drecn);
|
||||
gnc_time64_to_iso8601_buff (split->date_reconciled, drecn);
|
||||
|
||||
guid_to_string_buff (xaccSplitGetGUID(split), split_guid_str);
|
||||
amt = xaccSplitGetAmount (split);
|
||||
|
@ -310,7 +310,7 @@ gnc_transaction_get_property(GObject* object,
|
||||
{
|
||||
Transaction* tx;
|
||||
gchar *key;
|
||||
Timespec ts = {0,0};
|
||||
Time64 time;
|
||||
|
||||
g_return_if_fail(GNC_IS_TRANSACTION(object));
|
||||
|
||||
@ -327,12 +327,12 @@ gnc_transaction_get_property(GObject* object,
|
||||
g_value_take_object(value, tx->common_currency);
|
||||
break;
|
||||
case PROP_POST_DATE:
|
||||
ts.tv_sec = tx->date_posted;
|
||||
g_value_set_boxed(value, &ts);
|
||||
time.t = tx->date_posted;
|
||||
g_value_set_boxed(value, &time);
|
||||
break;
|
||||
case PROP_ENTER_DATE:
|
||||
ts.tv_sec = tx->date_entered;
|
||||
g_value_set_boxed(value, &ts);
|
||||
time.t = tx->date_entered;
|
||||
g_value_set_boxed(value, &time);
|
||||
break;
|
||||
case PROP_INVOICE:
|
||||
qof_instance_get_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
||||
@ -357,6 +357,7 @@ gnc_transaction_set_property(GObject* object,
|
||||
{
|
||||
Transaction* tx;
|
||||
gchar *key;
|
||||
Time64 *t;
|
||||
|
||||
g_return_if_fail(GNC_IS_TRANSACTION(object));
|
||||
|
||||
@ -375,10 +376,12 @@ gnc_transaction_set_property(GObject* object,
|
||||
xaccTransSetCurrency(tx, g_value_get_object(value));
|
||||
break;
|
||||
case PROP_POST_DATE:
|
||||
xaccTransSetDatePostedSecs(tx, ((Timespec*)g_value_get_boxed(value))->tv_sec);
|
||||
t = (Time64*)g_value_get_boxed(value);
|
||||
xaccTransSetDatePostedSecs(tx, t->t);
|
||||
break;
|
||||
case PROP_ENTER_DATE:
|
||||
xaccTransSetDateEnteredSecs(tx, ((Timespec*)g_value_get_boxed(value))->tv_sec);
|
||||
t = (Time64*)g_value_get_boxed(value);
|
||||
xaccTransSetDateEnteredSecs(tx, t->t);
|
||||
break;
|
||||
case PROP_INVOICE:
|
||||
qof_instance_set_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
||||
@ -446,7 +449,7 @@ gnc_transaction_class_init(TransactionClass* klass)
|
||||
g_param_spec_boxed("post-date",
|
||||
"Post Date",
|
||||
"The date the transaction occurred.",
|
||||
GNC_TYPE_TIMESPEC,
|
||||
GNC_TYPE_TIME64,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
@ -455,7 +458,7 @@ gnc_transaction_class_init(TransactionClass* klass)
|
||||
g_param_spec_boxed("enter-date",
|
||||
"Enter Date",
|
||||
"The date the transaction was entered.",
|
||||
GNC_TYPE_TIMESPEC,
|
||||
GNC_TYPE_TIME64,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(
|
||||
@ -530,8 +533,12 @@ xaccTransDump (const Transaction *trans, const char *tag)
|
||||
GList *node;
|
||||
|
||||
printf("%s Trans %p", tag, trans);
|
||||
printf(" Entered: %s\n", gnc_print_date(trans->date_entered));
|
||||
printf(" Posted: %s\n", gnc_print_date(trans->date_posted));
|
||||
memset(datebuff, 0, sizeof(datebuff));
|
||||
qof_print_date_buff(datebuff, sizeof(datebuff), trans->date_entered);
|
||||
printf(" Entered: %s\n", datebuff);
|
||||
memset(datebuff, 0, sizeof(datebuff));
|
||||
qof_print_date_buff(datebuff, sizeof(datebuff), trans->date_posted);
|
||||
printf(" Posted: %s\n", datebuff);
|
||||
printf(" Num: %s\n", trans->num ? trans->num : "(null)");
|
||||
printf(" Description: %s\n",
|
||||
trans->description ? trans->description : "(null)");
|
||||
@ -1955,7 +1962,7 @@ xaccTransSetDatePostedSecs (Transaction *trans, time64 secs)
|
||||
{
|
||||
if (!trans) return;
|
||||
xaccTransSetDateInternal(trans, &trans->date_posted, secs);
|
||||
set_gains_date_dirty (trans);
|
||||
set_gains_date_dirty(trans);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1974,7 +1981,7 @@ xaccTransSetDatePostedGDate (Transaction *trans, GDate date)
|
||||
|
||||
/* We additionally save this date into a kvp frame to ensure in
|
||||
* the future a date which was set as *date* (without time) can
|
||||
* clearly be distinguished from the Timespec. */
|
||||
* clearly be distinguished from the time64. */
|
||||
g_value_init (&v, G_TYPE_DATE);
|
||||
g_value_set_boxed (&v, &date);
|
||||
qof_instance_set_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_DATE_POSTED);
|
||||
@ -1992,25 +1999,21 @@ xaccTransSetDateEnteredSecs (Transaction *trans, time64 secs)
|
||||
}
|
||||
|
||||
static void
|
||||
qofTransSetDatePosted (Transaction *trans, Timespec ts)
|
||||
qofTransSetDatePosted (Transaction *trans, time64 time)
|
||||
{
|
||||
if (!trans) return;
|
||||
if ((ts.tv_nsec == 0) && (ts.tv_sec == 0)) return;
|
||||
if (!qof_begin_edit(&trans->inst)) return;
|
||||
xaccTransSetDateInternal(trans, &trans->date_posted, ts.tv_sec);
|
||||
xaccTransSetDateInternal(trans, &trans->date_posted, time);
|
||||
set_gains_date_dirty(trans);
|
||||
qof_commit_edit(&trans->inst);
|
||||
}
|
||||
|
||||
static void
|
||||
qofTransSetDateEntered (Transaction *trans, Timespec ts)
|
||||
qofTransSetDateEntered (Transaction *trans, time64 time)
|
||||
{
|
||||
/*This is called from the query framework, so we'll leave the timespec
|
||||
* until the query framework is converted, too.*/
|
||||
if (!trans) return;
|
||||
if ((ts.tv_nsec == 0) && (ts.tv_sec == 0)) return;
|
||||
if (!qof_begin_edit(&trans->inst)) return;
|
||||
xaccTransSetDateInternal(trans, &trans->date_entered, ts.tv_sec);
|
||||
xaccTransSetDateInternal(trans, &trans->date_entered, time);
|
||||
qof_commit_edit(&trans->inst);
|
||||
}
|
||||
|
||||
@ -2035,10 +2038,9 @@ void
|
||||
xaccTransSetDateDue (Transaction * trans, time64 time)
|
||||
{
|
||||
GValue v = G_VALUE_INIT;
|
||||
Timespec send_ts = {time, 0};
|
||||
if (!trans) return;
|
||||
g_value_init (&v, GNC_TYPE_TIMESPEC);
|
||||
g_value_set_boxed (&v, &send_ts);
|
||||
g_value_init (&v, GNC_TYPE_TIME64);
|
||||
g_value_set_boxed (&v, &time);
|
||||
xaccTransBeginEdit(trans);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||
@ -2384,7 +2386,7 @@ xaccTransGetDatePostedGDate (const Transaction *trans)
|
||||
/* Well, this txn doesn't have a GDate saved in a
|
||||
* slot. Avoid getting the date in the local TZ by
|
||||
* converting to UTC before generating the
|
||||
* date. (timespec_to_gdate doesn't do this so don't use
|
||||
* date. (time64_to_gdate doesn't do this so don't use
|
||||
* it.
|
||||
*/
|
||||
time64 time = xaccTransGetDate(trans);
|
||||
@ -2415,7 +2417,7 @@ xaccTransRetDateDue(const Transaction *trans)
|
||||
if (!trans) return 0;
|
||||
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
||||
if (G_VALUE_HOLDS_BOXED (&v))
|
||||
ret = ((Timespec*)g_value_get_boxed (&v))->tv_sec;
|
||||
ret = ((Time64*)g_value_get_boxed (&v))->t;
|
||||
if (!ret)
|
||||
return xaccTransRetDatePosted (trans);
|
||||
return ret;
|
||||
@ -2655,7 +2657,7 @@ xaccTransVoid(Transaction *trans, const char *reason)
|
||||
g_value_set_string (&v, reason);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_reason_str);
|
||||
|
||||
gnc_timespec_to_iso8601_buff (timespec_now (), iso8601_str);
|
||||
gnc_time64_to_iso8601_buff (gnc_time(NULL), iso8601_str);
|
||||
g_value_set_string (&v, iso8601_str);
|
||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, void_time_str);
|
||||
|
||||
@ -2940,39 +2942,6 @@ trans_is_balanced_p (const Transaction *trans)
|
||||
return trans ? xaccTransIsBalanced(trans) : FALSE;
|
||||
}
|
||||
|
||||
static Timespec
|
||||
xaccTransRetDateEnteredTS (Transaction * trans)
|
||||
{
|
||||
Timespec ret = {xaccTransRetDateEntered (trans), 0};
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
qofTransSetDateEnteredTS (Transaction * trans, Timespec t)
|
||||
{
|
||||
xaccTransSetDateEnteredSecs (trans, t.tv_sec);
|
||||
}
|
||||
|
||||
static Timespec
|
||||
xaccTransRetDatePostedTS (Transaction * trans)
|
||||
{
|
||||
Timespec ret = {xaccTransRetDatePosted (trans), 0};
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
qofTransSetDatePostedTS (Transaction * trans, Timespec t)
|
||||
{
|
||||
xaccTransSetDatePostedSecs (trans, t.tv_sec);
|
||||
}
|
||||
|
||||
static Timespec
|
||||
xaccTransRetDateDueTS (Transaction * trans)
|
||||
{
|
||||
Timespec ret = {xaccTransRetDateDue (trans), 0};
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean xaccTransRegister (void)
|
||||
{
|
||||
static QofParam params[] =
|
||||
|
@ -106,23 +106,21 @@ struct find_lot_s
|
||||
{
|
||||
GNCLot *lot;
|
||||
gnc_commodity *currency;
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
int (*numeric_pred)(gnc_numeric);
|
||||
gboolean (*date_pred)(Timespec e, Timespec tr);
|
||||
gboolean (*date_pred)(time64 e, time64 tr);
|
||||
};
|
||||
|
||||
static gboolean
|
||||
earliest_pred (Timespec earl, Timespec tran)
|
||||
earliest_pred (time64 earl, time64 tran)
|
||||
{
|
||||
return ((earl.tv_sec > tran.tv_sec) ||
|
||||
((earl.tv_sec == tran.tv_sec) && (earl.tv_nsec > tran.tv_nsec)));
|
||||
return earl > tran;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
latest_pred (Timespec earl, Timespec tran)
|
||||
latest_pred (time64 earl, time64 tran)
|
||||
{
|
||||
return ((earl.tv_sec < tran.tv_sec) ||
|
||||
((earl.tv_sec == tran.tv_sec) && (earl.tv_nsec < tran.tv_nsec)));
|
||||
return earl < tran;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
@ -133,7 +131,7 @@ finder_helper (GNCLot *lot, gpointer user_data)
|
||||
Transaction *trans;
|
||||
gnc_numeric bal;
|
||||
gboolean opening_is_positive, bal_is_positive;
|
||||
Timespec posted_ts = {0,0};
|
||||
time64 posted = 0;
|
||||
|
||||
if (gnc_lot_is_closed (lot)) return NULL;
|
||||
|
||||
@ -158,10 +156,10 @@ finder_helper (GNCLot *lot, gpointer user_data)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
posted_ts.tv_sec = trans->date_posted;
|
||||
if (els->date_pred (els->ts, posted_ts))
|
||||
posted = trans->date_posted;
|
||||
if (els->date_pred (els->time, posted))
|
||||
{
|
||||
els->ts.tv_sec = trans->date_posted;
|
||||
els->time = trans->date_posted;
|
||||
els->lot = lot;
|
||||
}
|
||||
|
||||
@ -172,14 +170,13 @@ static inline GNCLot *
|
||||
xaccAccountFindOpenLot (Account *acc, gnc_numeric sign,
|
||||
gnc_commodity *currency,
|
||||
gint64 guess,
|
||||
gboolean (*date_pred)(Timespec, Timespec))
|
||||
gboolean (*date_pred)(time64, time64))
|
||||
{
|
||||
struct find_lot_s es;
|
||||
|
||||
es.lot = NULL;
|
||||
es.currency = currency;
|
||||
es.ts.tv_sec = guess;
|
||||
es.ts.tv_nsec = 0;
|
||||
es.time = guess;
|
||||
es.date_pred = date_pred;
|
||||
|
||||
if (gnc_numeric_positive_p(sign)) es.numeric_pred = gnc_numeric_negative_p;
|
||||
@ -324,13 +321,12 @@ xaccSplitAssignToLot (Split *split, GNCLot *lot)
|
||||
/* If we are here, then (cmp == +1 iff (amt > baln)) and we need
|
||||
* to split up the split into pieces. Do it. */
|
||||
{
|
||||
time64 now = gnc_time (NULL);
|
||||
time64 now = gnc_time (NULL), time = 0;
|
||||
Split * new_split;
|
||||
gnc_numeric amt_a, amt_b, amt_tot;
|
||||
gnc_numeric val_a, val_b, val_tot;
|
||||
gnc_numeric frac;
|
||||
Transaction *trans;
|
||||
Timespec ts;
|
||||
|
||||
acc = split->acc;
|
||||
xaccAccountBeginEdit (acc);
|
||||
@ -400,8 +396,8 @@ xaccSplitAssignToLot (Split *split, GNCLot *lot)
|
||||
* split-action which is the same as xaccSplitGetAction */
|
||||
gnc_set_num_action(NULL, new_split, NULL, gnc_get_num_action(NULL, split));
|
||||
xaccSplitSetReconcile (new_split, xaccSplitGetReconcile (split));
|
||||
ts = xaccSplitRetDateReconciledTS (split);
|
||||
xaccSplitSetDateReconciledTS (new_split, &ts);
|
||||
time = xaccSplitGetDateReconciled (split);
|
||||
xaccSplitSetDateReconciledSecs (new_split, time);
|
||||
|
||||
/* Set the lot-split and peer_guid properties on the two
|
||||
* splits to indicate that they're linked.
|
||||
|
208
libgnucash/engine/engine-deprecated.c
Normal file
208
libgnucash/engine/engine-deprecated.c
Normal file
@ -0,0 +1,208 @@
|
||||
/********************************************************************\
|
||||
* engine-deprecated.i: Guile wrappers for deleted C functions. *
|
||||
* Copyright 2018 John Ralls <jralls@ceridwen.us> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/* The functions in this file have been removed from the C library and are
|
||||
* provided here for backward compatibility. They will be removed completely
|
||||
* from the next major release of GnuCash.
|
||||
*/
|
||||
|
||||
#include "engine-deprecated.h"
|
||||
|
||||
#include <libguile/deprecation.h>
|
||||
|
||||
void xaccSplitSetDateReconciledTS(Split* s, Timespec *ts)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("xaccSplitSetDateReconciled is deprecated. Use xaccSplitSetDateReconciledSecs instead.");
|
||||
xaccSplitSetDateReconciledSecs (s, ts->tv_sec);
|
||||
}
|
||||
|
||||
void xaccSplitGetDateReconciledTS(Split* s, Timespec *ts)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("xaccSplitGetDateReconciled is deprecated. Use xaccSplitGetDateReconciledSecs instead.");
|
||||
ts->tv_sec = xaccSplitGetDateReconciled (s);
|
||||
ts->tv_nsec = 0;
|
||||
}
|
||||
|
||||
Timespec xaccSplitRetDateReconciledTS(Split* s)
|
||||
{
|
||||
Timespec ts = {0, 0};
|
||||
scm_c_issue_deprecation_warning("xaccSplitSetDateReconciled is deprecated. Use xaccSplitSetDateReconciledSecs instead.");
|
||||
ts.tv_sec = xaccSplitGetDateReconciled (s);
|
||||
return ts;
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_transaction_get_date_posted(const Transaction *t)
|
||||
{
|
||||
Timespec ts = {0, 0};
|
||||
scm_c_issue_deprecation_warning("gnc_transaction_get_date_posted is deprecated. Use xaccTransRetDatePosted instead.");
|
||||
ts.tv_sec = xaccTransRetDatePosted(t);
|
||||
return ts;
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_transaction_get_date_entered(const Transaction *t)
|
||||
{
|
||||
Timespec ts = {0, 0};
|
||||
scm_c_issue_deprecation_warning("gnc_transaction_get_date_entered is deprecated. Use xaccTransGetDateEntered instead.");
|
||||
ts.tv_sec = xaccTransRetDateEntered(t);
|
||||
return ts;
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_split_get_date_reconciled(const Split *s)
|
||||
{
|
||||
Timespec ts = {0, 0};
|
||||
scm_c_issue_deprecation_warning("gnc_split_get_date_reconciled is deprecated. Use xaccSplitGetDateReconciled instead.");
|
||||
ts.tv_sec = xaccSplitGetDateReconciled(s);
|
||||
return ts;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_transaction_set_date(Transaction *t, Timespec ts)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_transaction_set_date is deprecated. Use xaccTransSetDatePostedSecs instead.");
|
||||
xaccTransSetDatePostedSecs(t, ts.tv_sec);
|
||||
}
|
||||
|
||||
Timespec
|
||||
gncTaxTableLastModified (const GncTaxTable *table)
|
||||
{
|
||||
Timespec t = {0, 0};
|
||||
scm_c_issue_deprecation_warning("gncTaxTableLastModified is deprecated. Use gncTaxTableLastModifiedSecs instead.");
|
||||
t.tv_sec = gncTaxTableLastModifiedSecs (table);
|
||||
return t;
|
||||
}
|
||||
|
||||
void
|
||||
gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn,
|
||||
GList *lots, Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, Timespec date,
|
||||
const char *memo, const char *num,
|
||||
gboolean auto_pay)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gncOwnerApplyPayment is deprecated. Use gncOwnerApplyPaymentSecs instead.");
|
||||
gncOwnerApplyPaymentSecs (owner, preset_txn, lots, posted_acc,
|
||||
xfer_acc, amount, exch, date.tv_sec,
|
||||
memo, num, auto_pay);
|
||||
}
|
||||
|
||||
GNCLot*
|
||||
gncOwnerCreatePaymentLot (const GncOwner *owner,
|
||||
Transaction **preset_txn, Account *posted_acc,
|
||||
Account *xfer_acc, gnc_numeric amount,
|
||||
gnc_numeric exch, Timespec date,
|
||||
const char *memo, const char *num)
|
||||
{
|
||||
GNCLot* lot = NULL;
|
||||
scm_c_issue_deprecation_warning("gncOwnerCreatePaymentLot is deprecated. Use gncOwnerCreatePaymentLotSecs instead.");
|
||||
lot = gncOwnerCreatePaymentLotSecs (owner, preset_txn, posted_acc,
|
||||
xfer_acc, amount, exch, date.tv_sec,
|
||||
memo, num);
|
||||
return lot;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_price_set_time (GNCPrice *p, Timespec t)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_price_set_time is deprecated. Use gnc_price_set_time64 instead.");
|
||||
gnc_price_set_time64(p, t.tv_sec);
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_price_get_time (GNCPrice *p)
|
||||
{
|
||||
Timespec t = {0, 0};
|
||||
scm_c_issue_deprecation_warning("gnc_price_get_time is deprecated. Use gnc_price_get_time64 instead.");
|
||||
t.tv_sec = gnc_price_get_time64(p);
|
||||
return t;
|
||||
}
|
||||
|
||||
GNCPrice*
|
||||
gnc_pricedb_lookup_at_time(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_pricedb_lookup_at_time is deprecated. Use gnc_pricedb_lookup_at_time64 instead.");
|
||||
return gnc_pricedb_lookup_at_time64(db, commodity, currency, t.tv_sec);
|
||||
}
|
||||
|
||||
GNCPrice*
|
||||
gnc_pricedb_lookup_day(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_pricedb_lookup_day is deprecated. Use gnc_pricedb_lookup_day_t64 instead.");
|
||||
return gnc_pricedb_lookup_day_t64(db, commodity, currency, t.tv_sec);
|
||||
}
|
||||
|
||||
GNCPrice*
|
||||
gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_pricedb_lookup_nearest_in_time is deprecated. Use gnc_pricedb_lookup_nearest_in_time64 instead.");
|
||||
return gnc_pricedb_lookup_nearest_in_time64(db, c, currency, t.tv_sec);
|
||||
}
|
||||
|
||||
PriceList*
|
||||
gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
Timespec t)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_pricedb_lookup_nearest_in_time_any_currency is deprecated. Use gnc_pricedb_lookup_nearest_in_time_any_currency_t64 instead.");
|
||||
return gnc_pricedb_lookup_nearest_in_time_any_currency_t64(db, c, t.tv_sec);
|
||||
}
|
||||
|
||||
GNCPrice*
|
||||
gnc_pricedb_lookup_latest_before(GNCPriceDB *db,
|
||||
gnc_commodity *c,
|
||||
gnc_commodity *currency,
|
||||
Timespec t)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_pricedb_lookup_latest_before is deprecated. Use gnc_pricedb_lookup_latest_before_t64 instead.");
|
||||
return gnc_pricedb_lookup_latest_before_t64(db, c, currency, t.tv_sec);
|
||||
}
|
||||
|
||||
PriceList*
|
||||
gnc_pricedb_lookup_latest_before_any_currency(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
Timespec t)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_pricedb_lookup_latest_before_any_currency is deprecated. Use gnc_pricedb_lookup_latest_before_any_currency_t64 instead.");
|
||||
return gnc_pricedb_lookup_latest_before_any_currency_t64(db, c, t.tv_sec);
|
||||
}
|
||||
|
||||
gnc_numeric
|
||||
gnc_pricedb_convert_balance_nearest_price(GNCPriceDB *pdb,
|
||||
gnc_numeric balance,
|
||||
const gnc_commodity *balance_currency,
|
||||
const gnc_commodity *new_currency,
|
||||
Timespec t)
|
||||
{
|
||||
scm_c_issue_deprecation_warning("gnc_pricedb_convert_balance_nearest_price is deprecated. Use gnc_pricedb_convert_balance_nearest_price_t64 instead.");
|
||||
return gnc_pricedb_convert_balance_nearest_price_t64(pdb, balance, balance_currency, new_currency, t.tv_sec);
|
||||
}
|
90
libgnucash/engine/engine-deprecated.h
Normal file
90
libgnucash/engine/engine-deprecated.h
Normal file
@ -0,0 +1,90 @@
|
||||
/********************************************************************\
|
||||
* engine-deprecated.h: Guile wrappers for deleted C functions. *
|
||||
* Copyright 2018 John Ralls <jralls@ceridwen.us> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "Split.h"
|
||||
#include "Transaction.h"
|
||||
#include "gncTaxTable.h"
|
||||
#include "gncOwner.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
time64 tv_sec;
|
||||
time64 tv_nsec;
|
||||
} Timespec;
|
||||
|
||||
|
||||
void xaccSplitSetDateReconciledTS(Split* s, Timespec *ts);
|
||||
void xaccSplitGetDateReconciledTS(Split* s, Timespec *ts);
|
||||
Timespec xaccSplitRetDateReconciledTS(Split* s);
|
||||
|
||||
Timespec gnc_transaction_get_date_posted(const Transaction *t);
|
||||
Timespec gnc_transaction_get_date_entered(const Transaction *t);
|
||||
Timespec gnc_split_get_date_reconciled(const Split *s);
|
||||
void gnc_transaction_set_date(Transaction *t, Timespec ts);
|
||||
|
||||
Timespec gncTaxTableLastModified (const GncTaxTable *table);
|
||||
|
||||
void gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn,
|
||||
GList *lots, Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, Timespec date,
|
||||
const char *memo, const char *num,
|
||||
gboolean auto_pay);
|
||||
|
||||
GNCLot* gncOwnerCreatePaymentLot (const GncOwner *owner,
|
||||
Transaction **preset_txn, Account *posted_acc,
|
||||
Account *xfer_acc, gnc_numeric amount,
|
||||
gnc_numeric exch, Timespec date,
|
||||
const char *memo, const char *num);
|
||||
|
||||
void gnc_price_set_time (GNCPrice *p, Timespec t);
|
||||
Timespec gnc_price_get_time (GNCPrice *p);
|
||||
GNCPrice* gnc_pricedb_lookup_at_time(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t);
|
||||
GNCPrice* gnc_pricedb_lookup_day(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t);
|
||||
GNCPrice* gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t);
|
||||
PriceList* gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
Timespec t);
|
||||
GNCPrice* gnc_pricedb_lookup_latest_before(GNCPriceDB *db,
|
||||
gnc_commodity *c,
|
||||
gnc_commodity *currency,
|
||||
Timespec t);
|
||||
PriceList* gnc_pricedb_lookup_latest_before_any_currency(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
Timespec t);
|
||||
gnc_numeric
|
||||
gnc_pricedb_convert_balance_nearest_price(GNCPriceDB *pdb,
|
||||
gnc_numeric balance,
|
||||
const gnc_commodity *balance_currency,
|
||||
const gnc_commodity *new_currency,
|
||||
Timespec t);
|
||||
|
@ -51,34 +51,6 @@ cannot be considered "standard" or public parts of QOF. */
|
||||
|
||||
static QofLogModule log_module = GNC_MOD_ENGINE;
|
||||
|
||||
Timespec
|
||||
gnc_transaction_get_date_posted(const Transaction *t)
|
||||
{
|
||||
Timespec ret = {xaccTransRetDatePosted(t), 0};
|
||||
return ret;
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_transaction_get_date_entered(const Transaction *t)
|
||||
{
|
||||
Timespec result = {xaccTransRetDateEntered(t), 0};
|
||||
return result;
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_split_get_date_reconciled(const Split *s)
|
||||
{
|
||||
Timespec result;
|
||||
xaccSplitGetDateReconciledTS(s, &result);
|
||||
return(result);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_transaction_set_date(Transaction *t, Timespec ts)
|
||||
{
|
||||
xaccTransSetDatePostedSecs(t, ts.tv_sec);
|
||||
}
|
||||
|
||||
/** Gets the transaction Number or split Action based on book option:
|
||||
* if the book option is TRUE (split action is used for NUM) and a
|
||||
* split is provided, split-action is returned; if book option is FALSE
|
||||
|
@ -34,13 +34,6 @@
|
||||
|
||||
typedef void (*GncBOCb) (gpointer new_val, gpointer user_data);
|
||||
|
||||
Timespec gnc_transaction_get_date_posted(const Transaction *t);
|
||||
Timespec gnc_transaction_get_date_entered(const Transaction *t);
|
||||
|
||||
Timespec gnc_split_get_date_reconciled(const Split *s);
|
||||
|
||||
void gnc_transaction_set_date(Transaction *t, Timespec ts);
|
||||
|
||||
/** Gets the transaction Number or split Action based on book option:
|
||||
* if the book option is TRUE (split action is used for NUM) and a
|
||||
* split is provided, split-action is returned; if book option is FALSE
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "gnc-lot.h"
|
||||
#include "gnc-session.h"
|
||||
#include "gnc-hooks-scm.h"
|
||||
#include "engine-deprecated.h"
|
||||
#include "engine-helpers.h"
|
||||
#include "engine-helpers-guile.h"
|
||||
#include "policy.h"
|
||||
@ -80,6 +81,7 @@ engine-common.i */
|
||||
%newobject gnc_account_get_full_name;
|
||||
|
||||
%include "engine-common.i"
|
||||
%include "engine-deprecated.h"
|
||||
|
||||
%inline %{
|
||||
static const GncGUID * gncPriceGetGUID(GNCPrice *x)
|
||||
@ -97,10 +99,14 @@ functions. */
|
||||
%newobject gnc_pricedb_lookup_latest_any_currency;
|
||||
|
||||
%newobject gnc_pricedb_lookup_nearest_in_time_any_currency;
|
||||
%newobject gnc_pricedb_lookup_nearest_in_time_any_currency_t64;
|
||||
%newobject gnc_pricedb_lookup_latest_before_any_currency;
|
||||
%newobject gnc_pricedb_lookup_latest_before_any_currency_t64;
|
||||
%newobject gnc_pricedb_get_prices;
|
||||
%newobject gnc_pricedb_lookup_at_time;
|
||||
%newobject gnc_pricedb_lookup_at_time64;
|
||||
%newobject gnc_pricedb_lookup_day;
|
||||
%newobject gnc_pricedb_lookup_day_t64;
|
||||
|
||||
%newobject xaccQueryGetSplitsUniqueTrans;
|
||||
%newobject xaccQueryGetTransactions;
|
||||
@ -207,7 +213,6 @@ SplitList * qof_query_run_subquery (QofQuery *q, const QofQuery *q);
|
||||
%ignore GNC_ERROR_REMAINDER;
|
||||
%include <gnc-numeric.h>
|
||||
|
||||
Timespec timespecCanonicalDayTime(Timespec t);
|
||||
time64 time64CanonicalDayTime(time64 t);
|
||||
|
||||
%include <gnc-budget.h>
|
||||
|
@ -74,7 +74,6 @@ const char *qof_win32_get_time_format(QofWin32Picture picture);
|
||||
/* Test Access for static functions */
|
||||
typedef struct
|
||||
{
|
||||
void (*timespec_normalize) (Timespec *t);
|
||||
GTimeZone* (*timezone_new_local) (void);
|
||||
} Testfuncs;
|
||||
|
||||
|
@ -378,114 +378,12 @@ gnc_print_time64(time64 time, const char* format)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
static void
|
||||
timespec_normalize(Timespec *t)
|
||||
{
|
||||
if (t->tv_nsec > NANOS_PER_SECOND)
|
||||
{
|
||||
t->tv_sec += (t->tv_nsec / NANOS_PER_SECOND);
|
||||
t->tv_nsec = t->tv_nsec % NANOS_PER_SECOND;
|
||||
}
|
||||
|
||||
if (t->tv_nsec < - NANOS_PER_SECOND)
|
||||
{
|
||||
t->tv_sec += - (-t->tv_nsec / NANOS_PER_SECOND);
|
||||
t->tv_nsec = - (-t->tv_nsec % NANOS_PER_SECOND);
|
||||
}
|
||||
|
||||
if (t->tv_sec > 0 && t->tv_nsec < 0)
|
||||
{
|
||||
t->tv_sec--;
|
||||
t->tv_nsec = NANOS_PER_SECOND + t->tv_nsec;
|
||||
}
|
||||
|
||||
if (t->tv_sec < 0 && t->tv_nsec > 0)
|
||||
{
|
||||
t->tv_sec++;
|
||||
t->tv_nsec = - NANOS_PER_SECOND + t->tv_nsec;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
gboolean
|
||||
timespec_equal (const Timespec *ta, const Timespec *tb)
|
||||
{
|
||||
Timespec pta, ptb;
|
||||
|
||||
if (ta == tb) return TRUE;
|
||||
/* Copy and normalize the copies */
|
||||
pta = *ta;
|
||||
ptb = *tb;
|
||||
timespec_normalize (&pta);
|
||||
timespec_normalize (&ptb);
|
||||
|
||||
if (pta.tv_sec != ptb.tv_sec) return FALSE;
|
||||
if (pta.tv_nsec != ptb.tv_nsec) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
timespec_cmp(const Timespec *ta, const Timespec *tb)
|
||||
{
|
||||
Timespec pta, ptb;
|
||||
|
||||
if (ta == tb) return 0;
|
||||
/* Copy and normalize the copies */
|
||||
pta = *ta;
|
||||
ptb = *tb;
|
||||
timespec_normalize (&pta);
|
||||
timespec_normalize (&ptb);
|
||||
|
||||
if (pta.tv_sec < ptb.tv_sec) return -1;
|
||||
if (pta.tv_sec > ptb.tv_sec) return 1;
|
||||
if (pta.tv_nsec < ptb.tv_nsec) return -1;
|
||||
if (pta.tv_nsec > ptb.tv_nsec) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Timespec
|
||||
timespec_diff(const Timespec *ta, const Timespec *tb)
|
||||
{
|
||||
Timespec retval;
|
||||
retval.tv_sec = ta->tv_sec - tb->tv_sec;
|
||||
retval.tv_nsec = ta->tv_nsec - tb->tv_nsec;
|
||||
timespec_normalize(&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
Timespec
|
||||
timespec_abs(const Timespec *t)
|
||||
{
|
||||
Timespec retval = *t;
|
||||
|
||||
timespec_normalize(&retval);
|
||||
if (retval.tv_sec < 0)
|
||||
{
|
||||
retval.tv_sec = - retval.tv_sec;
|
||||
retval.tv_nsec = - retval.tv_nsec;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Converts any time on a day to midday that day.
|
||||
|
||||
* given a timepair contains any time on a certain day (local time)
|
||||
* converts it to be midday that day.
|
||||
*/
|
||||
Timespec
|
||||
timespecCanonicalDayTime(Timespec t)
|
||||
{
|
||||
struct tm tm;
|
||||
Timespec retval;
|
||||
time64 t_secs = t.tv_sec + (t.tv_nsec / NANOS_PER_SECOND);
|
||||
gnc_localtime_r(&t_secs, &tm);
|
||||
gnc_tm_set_day_middle(&tm);
|
||||
retval.tv_sec = gnc_mktime(&tm);
|
||||
retval.tv_nsec = 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
time64
|
||||
time64CanonicalDayTime (time64 t)
|
||||
{
|
||||
@ -697,20 +595,6 @@ qof_print_date (time64 t)
|
||||
return g_strdup (buff);
|
||||
}
|
||||
|
||||
const char *
|
||||
gnc_print_date (Timespec ts)
|
||||
{
|
||||
static char buff[MAX_DATE_LENGTH];
|
||||
time64 t;
|
||||
|
||||
memset (buff, 0, sizeof (buff));
|
||||
t = ts.tv_sec + (time64)(ts.tv_nsec / 1000000000.0);
|
||||
|
||||
qof_print_date_buff (buff, MAX_DATE_LENGTH, t);
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
||||
/* ============================================================== */
|
||||
|
||||
/* return the greatest integer <= a/b; works for b > 0 and positive or
|
||||
@ -1229,21 +1113,14 @@ gnc_iso8601_to_time64_gmt(const char *cstr)
|
||||
|
||||
char *
|
||||
gnc_time64_to_iso8601_buff (time64 time, char * buff)
|
||||
{
|
||||
Timespec ts = {time, 0};
|
||||
return gnc_timespec_to_iso8601_buff (ts, buff);
|
||||
}
|
||||
|
||||
char *
|
||||
gnc_timespec_to_iso8601_buff (Timespec ts, char * buff)
|
||||
{
|
||||
constexpr size_t max_iso_date_length = 32;
|
||||
const char* format = "%Y-%m-%d %H:%M:%s %q";
|
||||
const char* format = "%Y-%m-%d %H:%M:%S %q";
|
||||
|
||||
if (! buff) return NULL;
|
||||
try
|
||||
{
|
||||
GncDateTime gncdt(ts.tv_sec);
|
||||
GncDateTime gncdt(time);
|
||||
auto sstr = gncdt.format(format);
|
||||
|
||||
memset(buff, 0, sstr.length() + 1);
|
||||
@ -1252,129 +1129,63 @@ gnc_timespec_to_iso8601_buff (Timespec ts, char * buff)
|
||||
}
|
||||
catch(std::logic_error& err)
|
||||
{
|
||||
PWARN("Error processing time64 %" PRId64 ": %s", ts.tv_sec, err.what());
|
||||
PWARN("Error processing time64 %" PRId64 ": %s", time, err.what());
|
||||
return buff;
|
||||
}
|
||||
catch(std::runtime_error& err)
|
||||
{
|
||||
PWARN("Error processing time64 %" PRId64 ": %s", ts.tv_sec, err.what());
|
||||
PWARN("Error processing time64 %" PRId64 ": %s", time, err.what());
|
||||
return buff;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnc_timespec2dmy (Timespec t, int *day, int *month, int *year)
|
||||
{
|
||||
struct tm result;
|
||||
time64 t_secs = t.tv_sec + (t.tv_nsec / NANOS_PER_SECOND);
|
||||
gnc_localtime_r(&t_secs, &result);
|
||||
|
||||
if (day) *day = result.tm_mday;
|
||||
if (month) *month = result.tm_mon + 1;
|
||||
if (year) *year = result.tm_year + 1900;
|
||||
}
|
||||
|
||||
#define THIRTY_TWO_YEARS 0x3c30fc00LL
|
||||
|
||||
static Timespec
|
||||
gnc_dmy2timespec_internal (int day, int month, int year, DayPart day_part)
|
||||
static time64
|
||||
gnc_dmy2time64_internal (int day, int month, int year, DayPart day_part)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto date = GncDate(year, month, day);
|
||||
return { static_cast<time64>(GncDateTime (date, day_part)), 0 };
|
||||
return static_cast<time64>(GncDateTime (date, day_part));
|
||||
}
|
||||
catch(const std::logic_error& err)
|
||||
{
|
||||
PWARN("Date computation error from Y-M-D %d-%d-%d: %s",
|
||||
year, month, day, err.what());
|
||||
return {INT64_MAX, 0};
|
||||
return INT64_MAX;
|
||||
}
|
||||
catch(const std::runtime_error& err)
|
||||
{
|
||||
PWARN("Date computation error from Y-M-D %d-%d-%d: %s",
|
||||
year, month, day, err.what());
|
||||
return {INT64_MAX, 0};
|
||||
return INT64_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
time64
|
||||
gnc_dmy2time64 (int day, int month, int year)
|
||||
{
|
||||
return gnc_dmy2timespec_internal (day, month, year, DayPart::start).tv_sec;
|
||||
return gnc_dmy2time64_internal (day, month, year, DayPart::start);
|
||||
}
|
||||
|
||||
time64
|
||||
gnc_dmy2time64_end (int day, int month, int year)
|
||||
{
|
||||
return gnc_dmy2timespec_internal (day, month, year, DayPart::end).tv_sec;
|
||||
return gnc_dmy2time64_internal (day, month, year, DayPart::end);
|
||||
}
|
||||
|
||||
time64
|
||||
gnc_dmy2time64_neutral (int day, int month, int year)
|
||||
{
|
||||
return gnc_dmy2timespec_internal (day, month, year, DayPart::neutral).tv_sec;
|
||||
return gnc_dmy2time64_internal (day, month, year, DayPart::neutral);
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_dmy2timespec (int day, int month, int year)
|
||||
{
|
||||
return gnc_dmy2timespec_internal (day, month, year, DayPart::start);
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_dmy2timespec_end (int day, int month, int year)
|
||||
{
|
||||
return gnc_dmy2timespec_internal (day, month, year, DayPart::end);
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_dmy2timespec_neutral (int day, int month, int year)
|
||||
{
|
||||
return gnc_dmy2timespec_internal (day, month, year, DayPart::neutral);
|
||||
}
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
void
|
||||
timespecFromTime64 ( Timespec *ts, time64 t )
|
||||
{
|
||||
ts->tv_sec = t;
|
||||
ts->tv_nsec = 0;
|
||||
}
|
||||
|
||||
Timespec
|
||||
timespec_now()
|
||||
{
|
||||
Timespec ts;
|
||||
ts.tv_sec = gnc_time(NULL);
|
||||
ts.tv_nsec = 0;
|
||||
return ts;
|
||||
}
|
||||
|
||||
time64
|
||||
timespecToTime64 (Timespec ts)
|
||||
{
|
||||
return ts.tv_sec;
|
||||
}
|
||||
|
||||
/* The GDate setter functions all in the end use g_date_set_time_t,
|
||||
* which in turn relies on localtime and is therefore subject to the
|
||||
* 2038 bug.
|
||||
*/
|
||||
GDate timespec_to_gdate (Timespec ts)
|
||||
{
|
||||
GDate result;
|
||||
|
||||
g_date_clear (&result, 1);
|
||||
GncDateTime time(ts.tv_sec);
|
||||
auto date = time.date().year_month_day();
|
||||
g_date_set_dmy (&result, date.day, static_cast<GDateMonth>(date.month),
|
||||
date.year);
|
||||
g_assert(g_date_valid (&result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GDate time64_to_gdate (time64 t)
|
||||
{
|
||||
GDate result;
|
||||
@ -1423,13 +1234,6 @@ time64 gdate_to_time64 (GDate d)
|
||||
g_date_get_year(&d));
|
||||
}
|
||||
|
||||
Timespec gdate_to_timespec (GDate d)
|
||||
{
|
||||
return gnc_dmy2timespec_neutral (g_date_get_day(&d),
|
||||
g_date_get_month(&d),
|
||||
g_date_get_year(&d));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tm_get_day_start (struct tm *tm, time64 time_val)
|
||||
{
|
||||
@ -1518,45 +1322,38 @@ gnc_dow_abbrev(gchar *buf, int buf_len, int dow)
|
||||
/* *******************************************************************
|
||||
* GValue handling
|
||||
********************************************************************/
|
||||
static gpointer
|
||||
timespec_boxed_copy_func( gpointer in_timespec )
|
||||
{
|
||||
Timespec* newvalue;
|
||||
|
||||
newvalue = static_cast<Timespec*>(g_malloc (sizeof (Timespec)));
|
||||
memcpy( newvalue, in_timespec, sizeof( Timespec ) );
|
||||
static gpointer
|
||||
time64_boxed_copy_func (gpointer in_time64)
|
||||
{
|
||||
Time64* newvalue;
|
||||
|
||||
newvalue = static_cast<Time64*>(g_malloc (sizeof (Time64)));
|
||||
memcpy (newvalue, in_time64, sizeof(Time64));
|
||||
|
||||
return newvalue;
|
||||
}
|
||||
|
||||
static void
|
||||
timespec_boxed_free_func( gpointer in_timespec )
|
||||
time64_boxed_free_func (gpointer in_time64)
|
||||
{
|
||||
g_free( in_timespec );
|
||||
g_free (in_time64);
|
||||
}
|
||||
|
||||
GType
|
||||
timespec_get_type( void )
|
||||
time64_get_type( void )
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if ( type == 0 )
|
||||
{
|
||||
type = g_boxed_type_register_static( "timespec",
|
||||
timespec_boxed_copy_func,
|
||||
timespec_boxed_free_func );
|
||||
type = g_boxed_type_register_static( "time64",
|
||||
time64_boxed_copy_func,
|
||||
time64_boxed_free_func );
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
Testfuncs*
|
||||
gnc_date_load_funcs (void)
|
||||
{
|
||||
Testfuncs *tf = g_slice_new (Testfuncs);
|
||||
tf->timespec_normalize = timespec_normalize;
|
||||
return tf;
|
||||
}
|
||||
|
||||
/* ================================================= */
|
||||
|
||||
gboolean
|
||||
@ -1810,3 +1607,10 @@ gnc_gdate_set_prev_fiscal_year_end (GDate *date,
|
||||
gnc_gdate_set_fiscal_year_end(date, fy_end);
|
||||
g_date_subtract_years(date, 1);
|
||||
}
|
||||
|
||||
Testfuncs*
|
||||
gnc_date_load_funcs (void)
|
||||
{
|
||||
Testfuncs *tf = g_slice_new (Testfuncs);
|
||||
return tf;
|
||||
}
|
||||
|
@ -82,22 +82,20 @@ extern "C"
|
||||
* this stops working in 2038, we define our own:
|
||||
*/
|
||||
typedef gint64 time64;
|
||||
|
||||
/** The Timespec is just like the unix 'struct timespec'
|
||||
* except that we use a 64-bit unsigned int to
|
||||
* store the seconds. This should adequately cover dates in the
|
||||
* distant future as well as the distant past, as long as they're not
|
||||
* more than a couple dozen times the age of the universe
|
||||
* Values of this type can range from -9,223,372,036,854,775,808 to
|
||||
* 9,223,372,036,854,775,807.
|
||||
/* A bit of a hack to create a type separate from the alias of int64_t so that
|
||||
* compile-time dispatch can use the right KVP visitor.
|
||||
*/
|
||||
typedef struct timespec64 Timespec;
|
||||
typedef struct
|
||||
{
|
||||
time64 t;
|
||||
} Time64;
|
||||
|
||||
|
||||
/** @name GValue
|
||||
@{
|
||||
*/
|
||||
GType timespec_get_type( void );
|
||||
#define GNC_TYPE_TIMESPEC (timespec_get_type ())
|
||||
GType time64_get_type( void );
|
||||
#define GNC_TYPE_TIME64 (time64_get_type ())
|
||||
|
||||
/** @} */
|
||||
/** The default date format for use with strftime. */
|
||||
@ -287,97 +285,29 @@ void gnc_gdate_set_today (GDate* gd);
|
||||
void gnc_gdate_set_time64 (GDate* gd, time64 time);
|
||||
|
||||
/** @} */
|
||||
|
||||
/* Datatypes *******************************************************/
|
||||
|
||||
/** \brief Use a 64-bit unsigned int timespec
|
||||
*
|
||||
* struct timespec64 is just like the unix 'struct timespec' except
|
||||
* that we use a 64-bit
|
||||
* unsigned int to store the seconds. This should adequately cover
|
||||
* dates in the distant future as well as the distant past, as long as
|
||||
* they're not more than a couple dozen times the age of the universe.
|
||||
* Values of this type can range from -9,223,372,036,854,775,808 to
|
||||
* 9,223,372,036,854,775,807.
|
||||
*/
|
||||
|
||||
#ifndef SWIG /* swig 1.1p5 can't hack the long long type */
|
||||
struct timespec64
|
||||
{
|
||||
time64 tv_sec;
|
||||
glong tv_nsec;
|
||||
};
|
||||
#endif /* SWIG */
|
||||
|
||||
|
||||
|
||||
/* Prototypes ******************************************************/
|
||||
|
||||
/** \name Timespec functions */
|
||||
// @{
|
||||
/** strict equality */
|
||||
gboolean timespec_equal(const Timespec *ta, const Timespec *tb);
|
||||
|
||||
/** comparison: if (ta < tb) -1; else if (ta > tb) 1; else 0; */
|
||||
gint timespec_cmp(const Timespec *ta, const Timespec *tb);
|
||||
|
||||
/** difference between ta and tb, results are normalized
|
||||
* ie tv_sec and tv_nsec of the result have the same size
|
||||
* abs(result.tv_nsec) <= 1000000000 */
|
||||
Timespec timespec_diff(const Timespec *ta, const Timespec *tb);
|
||||
|
||||
/** absolute value, also normalized */
|
||||
Timespec timespec_abs(const Timespec *t);
|
||||
|
||||
/** convert a timespec on a certain day (localtime) to
|
||||
* the timespec representing midday on that day. Watch out - this is *not* the
|
||||
/** convert a time64 on a certain day (localtime) to
|
||||
* the time64 representing midday on that day. Watch out - this is *not* the
|
||||
* first second of the day, which is returned by various other functions
|
||||
* returning a Timespec. */
|
||||
Timespec timespecCanonicalDayTime(Timespec t);
|
||||
|
||||
* returning a time64. */
|
||||
time64 time64CanonicalDayTime(time64 t);
|
||||
|
||||
/** Returns the current clock time as a Timespec, taken from time(2). */
|
||||
Timespec timespec_now (void);
|
||||
|
||||
/** Turns a time64 into a Timespec */
|
||||
void timespecFromTime64 (Timespec *ts, time64 t );
|
||||
|
||||
/** Turns a Timespec into a time64 */
|
||||
time64 timespecToTime64 (Timespec ts);
|
||||
|
||||
GDate time64_to_gdate (time64 t);
|
||||
|
||||
/** Turns a Timespec into a GDate */
|
||||
GDate timespec_to_gdate (Timespec ts);
|
||||
|
||||
/** Turns a GDate into a Timespec, returning the first second of the day */
|
||||
Timespec gdate_to_timespec (GDate d);
|
||||
|
||||
/** Turns a GDate into a time64, returning the first second of the day */
|
||||
time64 gdate_to_time64 (GDate d);
|
||||
|
||||
/** Convert a day, month, and year to a time64, returning the first second of the day */
|
||||
time64 gnc_dmy2time64 (gint day, gint month, gint year);
|
||||
|
||||
time64 gnc_dmy2time64_neutral (gint day, gint month, gint year);
|
||||
|
||||
time64 gnc_dmy2time64_end (gint day, gint month, gint year);
|
||||
|
||||
/** Convert a day, month, and year to a Timespec, returning the first second of the day */
|
||||
Timespec gnc_dmy2timespec (gint day, gint month, gint year);
|
||||
|
||||
/** Same as gnc_dmy2timespec, but last second of the day */
|
||||
Timespec gnc_dmy2timespec_end (gint day, gint month, gint year);
|
||||
|
||||
/** Converts a day, month, and year to a Timespec representing 11:00:00 UTC
|
||||
/** Converts a day, month, and year to a time64 representing 11:00:00 UTC
|
||||
* 11:00:00 UTC falls on the same time in almost all timezones, the exceptions
|
||||
* being the +13, +14, and -12 timezones used by countries along the
|
||||
* International Date Line. Since users in those timezones would see dates
|
||||
* immediately change by one day, the function checks the current timezone for
|
||||
* those changes and adjusts the UTC time so that the date will be consistent.
|
||||
*/
|
||||
Timespec gnc_dmy2timespec_neutral (gint day, gint month, gint year);
|
||||
time64 gnc_dmy2time64_neutral (gint day, gint month, gint year);
|
||||
|
||||
/** Same as gnc_dmy2time64, but last second of the day */
|
||||
time64 gnc_dmy2time64_end (gint day, gint month, gint year);
|
||||
|
||||
/** The gnc_iso8601_to_time64_gmt() routine converts an ISO-8601 style
|
||||
* date/time string to time64. Please note that ISO-8601 strings
|
||||
@ -397,8 +327,8 @@ Timespec gnc_dmy2timespec_neutral (gint day, gint month, gint year);
|
||||
*/
|
||||
time64 gnc_iso8601_to_time64_gmt(const gchar *);
|
||||
|
||||
/** The gnc_timespec_to_iso8601_buff() routine takes the input
|
||||
* UTC Timespec value and prints it as an ISO-8601 style string.
|
||||
/** The gnc_time64_to_iso8601_buff() routine takes the input
|
||||
* UTC time64 value and prints it as an ISO-8601 style string.
|
||||
* The buffer must be long enough to contain the NULL-terminated
|
||||
* string (32 characters + NUL). This routine returns a pointer
|
||||
* to the null terminator (and can thus be used in the 'stpcpy'
|
||||
@ -413,17 +343,7 @@ time64 gnc_iso8601_to_time64_gmt(const gchar *);
|
||||
* The string generated by this routine uses the local time zone
|
||||
* on the machine on which it is executing to create the time string.
|
||||
*/
|
||||
gchar * gnc_timespec_to_iso8601_buff (Timespec ts, gchar * buff);
|
||||
gchar * gnc_time64_to_iso8601_buff (time64, char * buff);
|
||||
|
||||
/** Set the proleptic Gregorian day, month, and year from a Timespec
|
||||
* \param ts: input timespec
|
||||
* \param day: output day, 1 - 31
|
||||
* \param month: output month, 1 - 12
|
||||
* \param year: output year, 0001 - 9999 CE
|
||||
*/
|
||||
void gnc_timespec2dmy (Timespec ts, gint *day, gint *month, gint *year);
|
||||
|
||||
// @}
|
||||
|
||||
/* ======================================================== */
|
||||
@ -556,13 +476,6 @@ size_t qof_print_gdate(char *buf, size_t bufflen, const GDate *gd);
|
||||
* **/
|
||||
char * qof_print_date (time64 secs);
|
||||
|
||||
/** Convenience; calls through to qof_print_date_dmy_buff().
|
||||
* Return: static global string.
|
||||
* \warning This routine is not thread-safe, because it uses a single
|
||||
* global buffer to store the return value. Use qof_print_date_buff()
|
||||
* or qof_print_date() instead.
|
||||
* **/
|
||||
const char * gnc_print_date(Timespec ts);
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* time printing utilities */
|
||||
@ -707,6 +620,11 @@ guint gnc_gdate_hash( gconstpointer gd );
|
||||
|
||||
/** \name GDate to time64 conversions */
|
||||
// @{
|
||||
/** Returns the GDate in which the time64 occurs.
|
||||
* @param t The time64
|
||||
* @returns A GDate for the day in which the time64 occurs.
|
||||
*/
|
||||
GDate time64_to_gdate (time64 t);
|
||||
|
||||
/** The gnc_time64_get_day_start() routine will take the given time in
|
||||
* GLib GDate format and adjust it to the first second of that day.
|
||||
|
@ -38,7 +38,7 @@ struct gnc_price_s
|
||||
GNCPriceDB *db;
|
||||
gnc_commodity *commodity;
|
||||
gnc_commodity *currency;
|
||||
Timespec tmspec;
|
||||
time64 tmspec;
|
||||
PriceSource source;
|
||||
char *type;
|
||||
gnc_numeric value;
|
||||
@ -82,7 +82,7 @@ typedef struct gnc_price_lookup_helper_s
|
||||
{
|
||||
GList **return_list;
|
||||
gnc_commodity *key;
|
||||
Timespec time;
|
||||
time64 time;
|
||||
} GNCPriceLookupHelper;
|
||||
|
||||
#define gnc_price_set_guid(P,G) qof_instance_set_guid(QOF_INSTANCE(P),(G))
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include "gnc-date.h"
|
||||
#include "gnc-pricedb-p.h"
|
||||
#include <qofinstance-p.h>
|
||||
@ -38,7 +39,7 @@ static gboolean add_price(GNCPriceDB *db, GNCPrice *p);
|
||||
static gboolean remove_price(GNCPriceDB *db, GNCPrice *p, gboolean cleanup);
|
||||
static GNCPrice *lookup_nearest_in_time(GNCPriceDB *db, const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t, gboolean sameday);
|
||||
time64 t, gboolean sameday);
|
||||
static gboolean
|
||||
pricedb_pricelist_traversal(GNCPriceDB *db,
|
||||
gboolean (*f)(GList *p, gpointer user_data),
|
||||
@ -61,6 +62,13 @@ typedef struct
|
||||
gpointer value;
|
||||
} HashEntry;
|
||||
|
||||
/* Like strcmp, returns -1 if a < b, +1 if a > b, and 0 if they're equal. */
|
||||
static inline int
|
||||
time64_cmp (time64 a, time64 b)
|
||||
{
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
}
|
||||
|
||||
static void
|
||||
hash_entry_insert(gpointer key, gpointer val, gpointer user_data)
|
||||
{
|
||||
@ -179,7 +187,7 @@ gnc_price_set_property(GObject* object, guint prop_id, const GValue* value, GPar
|
||||
{
|
||||
GNCPrice* price;
|
||||
gnc_numeric* number;
|
||||
Timespec* ts;
|
||||
Time64* time;
|
||||
|
||||
g_return_if_fail(GNC_IS_PRICE(object));
|
||||
|
||||
@ -205,8 +213,8 @@ gnc_price_set_property(GObject* object, guint prop_id, const GValue* value, GPar
|
||||
gnc_price_set_currency(price, g_value_get_object(value));
|
||||
break;
|
||||
case PROP_DATE:
|
||||
ts = g_value_get_boxed(value);
|
||||
gnc_price_set_time(price, *ts);
|
||||
time = g_value_get_boxed(value);
|
||||
gnc_price_set_time64(price, time->t);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
@ -380,7 +388,7 @@ gnc_price_clone (GNCPrice* p, QofBook *book)
|
||||
gnc_price_begin_edit(new_p);
|
||||
/* never ever clone guid's */
|
||||
gnc_price_set_commodity(new_p, gnc_price_get_commodity(p));
|
||||
gnc_price_set_time(new_p, gnc_price_get_time(p));
|
||||
gnc_price_set_time64(new_p, gnc_price_get_time64(p));
|
||||
gnc_price_set_source(new_p, gnc_price_get_source(p));
|
||||
gnc_price_set_typestr(new_p, gnc_price_get_typestr(p));
|
||||
gnc_price_set_value(new_p, gnc_price_get_value(p));
|
||||
@ -397,7 +405,7 @@ gnc_price_invert (GNCPrice *p)
|
||||
GNCPrice *new_p = gnc_price_create (book);
|
||||
qof_instance_copy_version(new_p, p);
|
||||
gnc_price_begin_edit(new_p);
|
||||
gnc_price_set_time(new_p, gnc_price_get_time(p));
|
||||
gnc_price_set_time64(new_p, gnc_price_get_time64(p));
|
||||
gnc_price_set_source(new_p, PRICE_SOURCE_TEMP);
|
||||
gnc_price_set_typestr(new_p, gnc_price_get_typestr(p));
|
||||
gnc_price_set_commodity(new_p, gnc_price_get_currency(p));
|
||||
@ -499,10 +507,10 @@ gnc_price_set_currency(GNCPrice *p, gnc_commodity *c)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_price_set_time(GNCPrice *p, Timespec t)
|
||||
gnc_price_set_time64(GNCPrice *p, time64 t)
|
||||
{
|
||||
if (!p) return;
|
||||
if (!timespec_equal(&(p->tmspec), &t))
|
||||
if (p->tmspec != t)
|
||||
{
|
||||
/* Changing the datestamp requires the hash table
|
||||
* position to be modified. The easiest way of doing
|
||||
@ -518,27 +526,6 @@ gnc_price_set_time(GNCPrice *p, Timespec t)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnc_price_set_time64(GNCPrice *p, time64 t64)
|
||||
{
|
||||
if (!p) return;
|
||||
if (p->tmspec.tv_sec != t64) // do we need to check nsec as well?
|
||||
{
|
||||
/* Changing the datestamp requires the hash table
|
||||
* position to be modified. The easiest way of doing
|
||||
* this is to remove and reinsert. */
|
||||
gnc_price_ref (p);
|
||||
remove_price (p->db, p, FALSE);
|
||||
gnc_price_begin_edit (p);
|
||||
p->tmspec.tv_sec = t64;
|
||||
p->tmspec.tv_nsec = 0;
|
||||
gnc_price_set_dirty(p);
|
||||
gnc_price_commit_edit (p);
|
||||
add_price (p->db, p);
|
||||
gnc_price_unref (p);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnc_price_set_source(GNCPrice *p, PriceSource s)
|
||||
{
|
||||
@ -616,21 +603,7 @@ gnc_price_get_commodity(const GNCPrice *p)
|
||||
time64
|
||||
gnc_price_get_time64(const GNCPrice *p)
|
||||
{
|
||||
if (!p) return 0;
|
||||
return p->tmspec.tv_sec;
|
||||
}
|
||||
|
||||
Timespec
|
||||
gnc_price_get_time(const GNCPrice *p)
|
||||
{
|
||||
if (!p)
|
||||
{
|
||||
Timespec result;
|
||||
result.tv_sec = 0;
|
||||
result.tv_nsec = 0;
|
||||
return result;
|
||||
}
|
||||
return p->tmspec;
|
||||
return p ? p->tmspec : 0;
|
||||
}
|
||||
|
||||
PriceSource
|
||||
@ -675,8 +648,7 @@ gnc_price_get_currency(const GNCPrice *p)
|
||||
gboolean
|
||||
gnc_price_equal (const GNCPrice *p1, const GNCPrice *p2)
|
||||
{
|
||||
Timespec ts1;
|
||||
Timespec ts2;
|
||||
time64 time1, time2;
|
||||
|
||||
if (p1 == p2) return TRUE;
|
||||
if (!p1 || !p2) return FALSE;
|
||||
@ -689,10 +661,10 @@ gnc_price_equal (const GNCPrice *p1, const GNCPrice *p2)
|
||||
gnc_price_get_currency (p2)))
|
||||
return FALSE;
|
||||
|
||||
ts1 = gnc_price_get_time (p1);
|
||||
ts2 = gnc_price_get_time (p2);
|
||||
time1 = gnc_price_get_time64 (p1);
|
||||
time2 = gnc_price_get_time64 (p2);
|
||||
|
||||
if (!timespec_equal (&ts1, &ts2))
|
||||
if (time1 != time2)
|
||||
return FALSE;
|
||||
|
||||
if (gnc_price_get_source (p1) != gnc_price_get_source (p2))
|
||||
@ -715,18 +687,18 @@ gnc_price_equal (const GNCPrice *p1, const GNCPrice *p2)
|
||||
static gint
|
||||
compare_prices_by_date(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
Timespec time_a;
|
||||
Timespec time_b;
|
||||
time64 time_a, time_b;
|
||||
gint result;
|
||||
|
||||
if (!a && !b) return 0;
|
||||
/* nothing is always less than something */
|
||||
if (!a) return -1;
|
||||
|
||||
time_a = gnc_price_get_time((GNCPrice *) a);
|
||||
time_b = gnc_price_get_time((GNCPrice *) b);
|
||||
time_a = gnc_price_get_time64((GNCPrice *) a);
|
||||
time_b = gnc_price_get_time64((GNCPrice *) b);
|
||||
|
||||
result = -timespec_cmp(&time_a, &time_b);
|
||||
/* Note we return -1 if time_b is before time_a. */
|
||||
result = time64_cmp(time_b, time_a);
|
||||
if (result) return result;
|
||||
|
||||
/* For a stable sort */
|
||||
@ -745,17 +717,17 @@ price_list_is_duplicate( gpointer data, gpointer user_data )
|
||||
{
|
||||
GNCPrice* pPrice = (GNCPrice*)data;
|
||||
PriceListIsDuplStruct* pStruct = (PriceListIsDuplStruct*)user_data;
|
||||
Timespec time_a, time_b;
|
||||
time64 time_a, time_b;
|
||||
|
||||
time_a = timespecCanonicalDayTime( gnc_price_get_time( pPrice ) );
|
||||
time_b = timespecCanonicalDayTime( gnc_price_get_time( pStruct->pPrice ) );
|
||||
time_a = time64CanonicalDayTime( gnc_price_get_time64( pPrice ) );
|
||||
time_b = time64CanonicalDayTime( gnc_price_get_time64( pStruct->pPrice ) );
|
||||
|
||||
/* If the date, currency, commodity and price match, it's a duplicate */
|
||||
if ( !gnc_numeric_equal( gnc_price_get_value( pPrice ), gnc_price_get_value( pStruct->pPrice ) ) ) return;
|
||||
if ( gnc_price_get_commodity( pPrice ) != gnc_price_get_commodity( pStruct->pPrice ) ) return;
|
||||
if ( gnc_price_get_currency( pPrice ) != gnc_price_get_currency( pStruct->pPrice ) ) return;
|
||||
|
||||
if ( timespec_cmp( &time_a, &time_b ) != 0 ) return;
|
||||
if (time_a != time_b) return;
|
||||
|
||||
pStruct->isDupl = TRUE;
|
||||
}
|
||||
@ -1137,7 +1109,7 @@ add_price(GNCPriceDB *db, GNCPrice *p)
|
||||
* add this one. If this price is of equal or better precedence than the old
|
||||
* one, copy this one over the old one.
|
||||
*/
|
||||
old_price = gnc_pricedb_lookup_day (db, p->commodity, p->currency,
|
||||
old_price = gnc_pricedb_lookup_day_t64 (db, p->commodity, p->currency,
|
||||
p->tmspec);
|
||||
if (!db->bulk_update && old_price != NULL)
|
||||
{
|
||||
@ -1299,15 +1271,18 @@ gboolean
|
||||
gnc_pricedb_remove_price(GNCPriceDB *db, GNCPrice *p)
|
||||
{
|
||||
gboolean rc;
|
||||
char datebuff[MAX_DATE_LENGTH + 1];
|
||||
memset(datebuff, 0, sizeof(datebuff));
|
||||
if (!db || !p) return FALSE;
|
||||
ENTER ("db=%p, pr=%p dirty=%d destroying=%d",
|
||||
db, p, qof_instance_get_dirty_flag(p),
|
||||
qof_instance_get_destroying(p));
|
||||
|
||||
gnc_price_ref(p);
|
||||
|
||||
DEBUG("Remove Date is %s, Commodity is %s, Source is %s", gnc_print_date (gnc_price_get_time (p)),
|
||||
gnc_commodity_get_fullname (gnc_price_get_commodity (p)), gnc_price_get_source_string (p));
|
||||
qof_print_date_buff(datebuff, sizeof(datebuff), gnc_price_get_time64 (p));
|
||||
DEBUG("Remove Date is %s, Commodity is %s, Source is %s", datebuff,
|
||||
gnc_commodity_get_fullname (gnc_price_get_commodity (p)),
|
||||
gnc_price_get_source_string (p));
|
||||
|
||||
rc = remove_price (db, p, TRUE);
|
||||
gnc_pricedb_begin_edit(db);
|
||||
@ -1327,7 +1302,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;
|
||||
@ -1339,7 +1314,7 @@ check_one_price_date (GNCPrice *price, gpointer user_data)
|
||||
{
|
||||
remove_info *data = user_data;
|
||||
PriceSource source;
|
||||
Timespec pt;
|
||||
time64 time;
|
||||
|
||||
ENTER("price %p (%s), data %p", price,
|
||||
gnc_commodity_get_mnemonic(gnc_price_get_commodity(price)),
|
||||
@ -1359,13 +1334,13 @@ check_one_price_date (GNCPrice *price, gpointer user_data)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
pt = gnc_price_get_time (price);
|
||||
time = gnc_price_get_time64 (price);
|
||||
{
|
||||
gchar buf[40];
|
||||
gnc_timespec_to_iso8601_buff(pt , buf);
|
||||
gnc_time64_to_iso8601_buff(time, buf);
|
||||
DEBUG("checking date %s", buf);
|
||||
}
|
||||
if (timespec_cmp (&pt, &data->cutoff) < 0)
|
||||
if (time < data->cutoff)
|
||||
{
|
||||
data->list = g_slist_prepend(data->list, price);
|
||||
DEBUG("will delete");
|
||||
@ -1394,8 +1369,7 @@ pricedb_remove_foreach_pricelist (gpointer key,
|
||||
static gint
|
||||
compare_prices_by_commodity_date (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
Timespec time_a;
|
||||
Timespec time_b;
|
||||
time64 time_a, time_b;
|
||||
gnc_commodity *comma;
|
||||
gnc_commodity *commb;
|
||||
gnc_commodity *curra;
|
||||
@ -1419,10 +1393,11 @@ compare_prices_by_commodity_date (gconstpointer a, gconstpointer b)
|
||||
if (!gnc_commodity_equal(curra, currb))
|
||||
return gnc_commodity_compare(curra, currb);
|
||||
|
||||
time_a = gnc_price_get_time((GNCPrice *) a);
|
||||
time_b = gnc_price_get_time((GNCPrice *) b);
|
||||
time_a = gnc_price_get_time64((GNCPrice *) a);
|
||||
time_b = gnc_price_get_time64((GNCPrice *) b);
|
||||
|
||||
result = -timespec_cmp(&time_a, &time_b);
|
||||
/* Note we return -1 if time_b is before time_a. */
|
||||
result = time64_cmp(time_b, time_a);
|
||||
if (result) return result;
|
||||
|
||||
/* For a stable sort */
|
||||
@ -1448,7 +1423,7 @@ price_commodity_and_currency_equal (GNCPrice *a, GNCPrice *b)
|
||||
static void
|
||||
gnc_pricedb_remove_old_prices_pinfo (GNCPrice *price, gboolean keep_message)
|
||||
{
|
||||
GDate price_date = timespec_to_gdate (gnc_price_get_time (price));
|
||||
GDate price_date = time64_to_gdate (gnc_price_get_time64 (price));
|
||||
char date_buf[MAX_DATE_LENGTH+1];
|
||||
|
||||
if (g_date_valid (&price_date))
|
||||
@ -1557,8 +1532,8 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date,
|
||||
}
|
||||
|
||||
// get the price dates
|
||||
saved_price_date = timespec_to_gdate (gnc_price_get_time (cloned_price));
|
||||
next_price_date = timespec_to_gdate (gnc_price_get_time (item->data));
|
||||
saved_price_date = time64_to_gdate (gnc_price_get_time64 (cloned_price));
|
||||
next_price_date = time64_to_gdate (gnc_price_get_time64 (item->data));
|
||||
|
||||
// Keep last price in fiscal year
|
||||
if (keep == PRICE_REMOVE_KEEP_LAST_PERIOD && save_first_price == FALSE)
|
||||
@ -1625,12 +1600,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, 0, sizeof(datebuff));
|
||||
|
||||
data.db = db;
|
||||
data.cutoff = cutoff;
|
||||
@ -1663,7 +1640,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)
|
||||
@ -1806,8 +1785,7 @@ pricedb_get_prices_internal(GNCPriceDB *db, const gnc_commodity *commodity,
|
||||
return forward_list;
|
||||
}
|
||||
|
||||
GNCPrice *
|
||||
gnc_pricedb_lookup_latest(GNCPriceDB *db,
|
||||
GNCPrice *gnc_pricedb_lookup_latest(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency)
|
||||
{
|
||||
@ -1833,7 +1811,7 @@ typedef struct
|
||||
{
|
||||
GList **list;
|
||||
const gnc_commodity *com;
|
||||
Timespec t;
|
||||
time64 t;
|
||||
} UsesCommodity;
|
||||
|
||||
/* price_list_scan_any_currency is the helper function used with
|
||||
@ -1871,8 +1849,8 @@ price_list_scan_any_currency(GList *price_list, gpointer data)
|
||||
while (node != NULL)
|
||||
{
|
||||
GNCPrice *price = node->data;
|
||||
Timespec price_t = gnc_price_get_time(price);
|
||||
if (timespec_cmp(&price_t, &helper->t) < 0)
|
||||
time64 price_t = gnc_price_get_time64(price);
|
||||
if (price_t < helper->t)
|
||||
{
|
||||
/* If there is a previous price add it to the results. */
|
||||
if (node->prev)
|
||||
@ -1913,7 +1891,7 @@ is_in_list (GList *list, const gnc_commodity *c)
|
||||
* want only the first one before the specified time containing both the target
|
||||
* and some other commodity. */
|
||||
static PriceList*
|
||||
latest_before (PriceList *prices, const gnc_commodity* target, Timespec t)
|
||||
latest_before (PriceList *prices, const gnc_commodity* target, time64 t)
|
||||
{
|
||||
GList *node, *found_coms = NULL, *retval = NULL;
|
||||
for (node = prices; node != NULL; node = g_list_next(node))
|
||||
@ -1921,8 +1899,8 @@ latest_before (PriceList *prices, const gnc_commodity* target, Timespec t)
|
||||
GNCPrice *price = (GNCPrice*)node->data;
|
||||
gnc_commodity *com = gnc_price_get_commodity(price);
|
||||
gnc_commodity *cur = gnc_price_get_currency(price);
|
||||
Timespec price_t = gnc_price_get_time(price);
|
||||
if (timespec_cmp(&t, &price_t) <= 0 ||
|
||||
time64 price_t = gnc_price_get_time64(price);
|
||||
if (t < price_t ||
|
||||
(com == target && is_in_list(found_coms, cur)) ||
|
||||
(cur == target && is_in_list(found_coms, com)))
|
||||
continue;
|
||||
@ -1953,14 +1931,14 @@ find_comtime(GPtrArray* array, gnc_commodity *com)
|
||||
|
||||
static GList*
|
||||
add_nearest_price(GList *target_list, GPtrArray *price_array, GNCPrice *price,
|
||||
const gnc_commodity *target, Timespec t)
|
||||
const gnc_commodity *target, time64 t)
|
||||
{
|
||||
gnc_commodity *com = gnc_price_get_commodity(price);
|
||||
gnc_commodity *cur = gnc_price_get_currency(price);
|
||||
Timespec price_t = gnc_price_get_time(price);
|
||||
time64 price_t = gnc_price_get_time64(price);
|
||||
gnc_commodity *other = com == target ? cur : com;
|
||||
GNCPrice **com_price = find_comtime(price_array, other);
|
||||
Timespec com_t;
|
||||
time64 com_t;
|
||||
if (com_price == NULL)
|
||||
{
|
||||
com_price = (GNCPrice**)g_slice_new(gpointer);
|
||||
@ -1968,19 +1946,19 @@ add_nearest_price(GList *target_list, GPtrArray *price_array, GNCPrice *price,
|
||||
g_ptr_array_add(price_array, com_price);
|
||||
/* If the first price we see for this commodity is not newer than
|
||||
the target date add it to the return list. */
|
||||
if (timespec_cmp(&price_t, &t) <= 0)
|
||||
if (price_t <= t)
|
||||
{
|
||||
gnc_price_ref(price);
|
||||
target_list = g_list_prepend(target_list, price);
|
||||
}
|
||||
return target_list;
|
||||
}
|
||||
com_t = gnc_price_get_time(*com_price);
|
||||
if (timespec_cmp(&com_t, &t) <= 0)
|
||||
com_t = gnc_price_get_time64(*com_price);
|
||||
if (com_t <= t)
|
||||
/* No point in checking any more prices, they'll all be further from
|
||||
* t. */
|
||||
return target_list;
|
||||
if (timespec_cmp(&price_t, &t) > 0)
|
||||
if (price_t > t)
|
||||
/* The price list is sorted newest->oldest, so as long as this price
|
||||
* is newer than t then it should replace the saved one. */
|
||||
{
|
||||
@ -1988,9 +1966,9 @@ add_nearest_price(GList *target_list, GPtrArray *price_array, GNCPrice *price,
|
||||
}
|
||||
else
|
||||
{
|
||||
Timespec com_diff = timespec_diff(&com_t, &t);
|
||||
Timespec price_diff = timespec_diff(&t, &price_t);
|
||||
if (timespec_cmp(&com_diff, &price_diff) < 0)
|
||||
time64 com_diff = com_t - t;
|
||||
time64 price_diff = t - price_t;
|
||||
if (com_diff < price_diff)
|
||||
{
|
||||
gnc_price_ref(*com_price);
|
||||
target_list = g_list_prepend(target_list, *com_price);
|
||||
@ -2006,7 +1984,7 @@ add_nearest_price(GList *target_list, GPtrArray *price_array, GNCPrice *price,
|
||||
}
|
||||
|
||||
static PriceList *
|
||||
nearest_to (PriceList *prices, const gnc_commodity* target, Timespec t)
|
||||
nearest_to (PriceList *prices, const gnc_commodity* target, time64 t)
|
||||
{
|
||||
GList *node, *retval = NULL;
|
||||
const guint prealloc_size = 5; /*More than 5 "other" is unlikely as long as
|
||||
@ -2028,8 +2006,8 @@ nearest_to (PriceList *prices, const gnc_commodity* target, Timespec t)
|
||||
for (index = 0; index < price_array->len; ++index)
|
||||
{
|
||||
GNCPrice **com_price = g_ptr_array_index(price_array, index);
|
||||
Timespec price_t = gnc_price_get_time(*com_price);
|
||||
if (timespec_cmp(&price_t, &t) >= 0)
|
||||
time64 price_t = gnc_price_get_time64(*com_price);
|
||||
if (price_t >= t)
|
||||
{
|
||||
gnc_price_ref(*com_price);
|
||||
retval = g_list_prepend(retval, *com_price);
|
||||
@ -2045,13 +2023,14 @@ PriceList *
|
||||
gnc_pricedb_lookup_latest_any_currency(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity)
|
||||
{
|
||||
return gnc_pricedb_lookup_latest_before_any_currency(db, commodity, timespec_now());
|
||||
return gnc_pricedb_lookup_latest_before_any_currency_t64(db, commodity,
|
||||
gnc_time(NULL));
|
||||
}
|
||||
|
||||
PriceList *
|
||||
gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
Timespec t)
|
||||
gnc_pricedb_lookup_nearest_in_time_any_currency_t64(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
time64 t)
|
||||
{
|
||||
GList *prices = NULL, *result;
|
||||
UsesCommodity helper = {&prices, commodity, t};
|
||||
@ -2060,8 +2039,7 @@ gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db,
|
||||
if (!db || !commodity) return NULL;
|
||||
ENTER ("db=%p commodity=%p", db, commodity);
|
||||
|
||||
pricedb_pricelist_traversal(db, price_list_scan_any_currency,
|
||||
&helper);
|
||||
pricedb_pricelist_traversal(db, price_list_scan_any_currency, &helper);
|
||||
prices = g_list_sort(prices, compare_prices_by_date);
|
||||
result = nearest_to(prices, commodity, t);
|
||||
gnc_price_list_destroy(prices);
|
||||
@ -2070,21 +2048,9 @@ gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db,
|
||||
}
|
||||
|
||||
PriceList *
|
||||
gnc_pricedb_lookup_nearest_in_time_any_currency_t64(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
time64 t64)
|
||||
{
|
||||
Timespec t;
|
||||
t.tv_sec = t64;
|
||||
t.tv_nsec = 0;
|
||||
|
||||
return gnc_pricedb_lookup_nearest_in_time_any_currency(db, commodity, t);
|
||||
}
|
||||
|
||||
PriceList *
|
||||
gnc_pricedb_lookup_latest_before_any_currency(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
Timespec t)
|
||||
gnc_pricedb_lookup_latest_before_any_currency_t64(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
time64 t)
|
||||
{
|
||||
GList *prices = NULL, *result;
|
||||
UsesCommodity helper = {&prices, commodity, t};
|
||||
@ -2283,32 +2249,20 @@ gnc_pricedb_nth_price (GNCPriceDB *db,
|
||||
return result;
|
||||
}
|
||||
|
||||
GNCPrice *
|
||||
gnc_pricedb_lookup_day(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t)
|
||||
{
|
||||
return lookup_nearest_in_time(db, c, currency, t, TRUE);
|
||||
}
|
||||
|
||||
GNCPrice *
|
||||
gnc_pricedb_lookup_day_t64(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
time64 t64)
|
||||
{
|
||||
Timespec t;
|
||||
t.tv_sec = t64;
|
||||
t.tv_nsec = 0;
|
||||
return lookup_nearest_in_time(db, c, currency, t, TRUE);
|
||||
}
|
||||
|
||||
GNCPrice *
|
||||
gnc_pricedb_lookup_at_time(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t)
|
||||
time64 t)
|
||||
{
|
||||
return lookup_nearest_in_time(db, c, currency, t, TRUE);
|
||||
}
|
||||
|
||||
GNCPrice *
|
||||
gnc_pricedb_lookup_at_time64(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
time64 t)
|
||||
{
|
||||
GList *price_list;
|
||||
GList *item = NULL;
|
||||
@ -2320,8 +2274,8 @@ gnc_pricedb_lookup_at_time(GNCPriceDB *db,
|
||||
while (item)
|
||||
{
|
||||
GNCPrice *p = item->data;
|
||||
Timespec price_time = gnc_price_get_time(p);
|
||||
if (timespec_equal(&price_time, &t))
|
||||
time64 price_time = gnc_price_get_time64(p);
|
||||
if (price_time == t)
|
||||
{
|
||||
gnc_price_ref(p);
|
||||
g_list_free (price_list);
|
||||
@ -2338,7 +2292,7 @@ static GNCPrice *
|
||||
lookup_nearest_in_time(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t,
|
||||
time64 t,
|
||||
gboolean sameday)
|
||||
{
|
||||
GList *price_list;
|
||||
@ -2348,7 +2302,7 @@ lookup_nearest_in_time(GNCPriceDB *db,
|
||||
GList *item = NULL;
|
||||
|
||||
if (!db || !c || !currency) return NULL;
|
||||
if (t.tv_sec == INT64_MAX) return NULL;
|
||||
if (t == INT64_MAX) return NULL;
|
||||
ENTER ("db=%p commodity=%p currency=%p", db, c, currency);
|
||||
price_list = pricedb_get_prices_internal (db, c, currency, TRUE);
|
||||
if (!price_list) return NULL;
|
||||
@ -2362,8 +2316,8 @@ lookup_nearest_in_time(GNCPriceDB *db,
|
||||
while (!next_price && item)
|
||||
{
|
||||
GNCPrice *p = item->data;
|
||||
Timespec price_time = gnc_price_get_time(p);
|
||||
if (timespec_cmp(&price_time, &t) <= 0)
|
||||
time64 price_time = gnc_price_get_time64(p);
|
||||
if (price_time <= t)
|
||||
{
|
||||
next_price = item->data;
|
||||
break;
|
||||
@ -2381,11 +2335,11 @@ lookup_nearest_in_time(GNCPriceDB *db,
|
||||
if (sameday)
|
||||
{
|
||||
/* Must be on the same day. */
|
||||
Timespec price_day;
|
||||
Timespec t_day;
|
||||
price_day = timespecCanonicalDayTime(gnc_price_get_time(current_price));
|
||||
t_day = timespecCanonicalDayTime(t);
|
||||
if (!timespec_equal(&price_day, &t_day))
|
||||
time64 price_day;
|
||||
time64 t_day;
|
||||
price_day = time64CanonicalDayTime(gnc_price_get_time64(current_price));
|
||||
t_day = time64CanonicalDayTime(t);
|
||||
if (price_day != t_day)
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
@ -2393,25 +2347,25 @@ lookup_nearest_in_time(GNCPriceDB *db,
|
||||
{
|
||||
/* If the requested time is not earlier than the first price on the
|
||||
list, then current_price and next_price will be the same. */
|
||||
Timespec current_t = gnc_price_get_time(current_price);
|
||||
Timespec next_t = gnc_price_get_time(next_price);
|
||||
Timespec diff_current = timespec_diff(¤t_t, &t);
|
||||
Timespec diff_next = timespec_diff(&next_t, &t);
|
||||
Timespec abs_current = timespec_abs(&diff_current);
|
||||
Timespec abs_next = timespec_abs(&diff_next);
|
||||
time64 current_t = gnc_price_get_time64(current_price);
|
||||
time64 next_t = gnc_price_get_time64(next_price);
|
||||
time64 diff_current = current_t - t;
|
||||
time64 diff_next = next_t - t;
|
||||
time64 abs_current = llabs(diff_current);
|
||||
time64 abs_next = llabs(diff_next);
|
||||
|
||||
if (sameday)
|
||||
{
|
||||
/* Result must be on same day, see if either of the two isn't */
|
||||
Timespec t_day = timespecCanonicalDayTime(t);
|
||||
Timespec current_day = timespecCanonicalDayTime(current_t);
|
||||
Timespec next_day = timespecCanonicalDayTime(next_t);
|
||||
if (timespec_equal(¤t_day, &t_day))
|
||||
time64 t_day = time64CanonicalDayTime(t);
|
||||
time64 current_day = time64CanonicalDayTime(current_t);
|
||||
time64 next_day = time64CanonicalDayTime(next_t);
|
||||
if (current_day == t_day)
|
||||
{
|
||||
if (timespec_equal(&next_day, &t_day))
|
||||
if (next_day == t_day)
|
||||
{
|
||||
/* Both on same day, return nearest */
|
||||
if (timespec_cmp(&abs_current, &abs_next) < 0)
|
||||
if (abs_current < abs_next)
|
||||
result = current_price;
|
||||
else
|
||||
result = next_price;
|
||||
@ -2420,7 +2374,7 @@ lookup_nearest_in_time(GNCPriceDB *db,
|
||||
/* current_price on same day, next_price not */
|
||||
result = current_price;
|
||||
}
|
||||
else if (timespec_equal(&next_day, &t_day))
|
||||
else if (next_day == t_day)
|
||||
/* next_price on same day, current_price not */
|
||||
result = next_price;
|
||||
}
|
||||
@ -2429,7 +2383,7 @@ lookup_nearest_in_time(GNCPriceDB *db,
|
||||
/* Choose the price that is closest to the given time. In case of
|
||||
* a tie, prefer the older price since it actually existed at the
|
||||
* time. (This also fixes bug #541970.) */
|
||||
if (timespec_cmp(&abs_current, &abs_next) < 0)
|
||||
if (abs_current < abs_next)
|
||||
{
|
||||
result = current_price;
|
||||
}
|
||||
@ -2447,39 +2401,28 @@ lookup_nearest_in_time(GNCPriceDB *db,
|
||||
return result;
|
||||
}
|
||||
|
||||
GNCPrice *
|
||||
gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t)
|
||||
{
|
||||
return lookup_nearest_in_time(db, c, currency, t, FALSE);
|
||||
}
|
||||
|
||||
GNCPrice *
|
||||
gnc_pricedb_lookup_nearest_in_time64(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
time64 t64)
|
||||
time64 t)
|
||||
{
|
||||
Timespec t;
|
||||
t.tv_sec = t64;
|
||||
t.tv_nsec = 0;
|
||||
return lookup_nearest_in_time(db, c, currency, t, FALSE);
|
||||
}
|
||||
|
||||
|
||||
GNCPrice *
|
||||
gnc_pricedb_lookup_latest_before (GNCPriceDB *db,
|
||||
gnc_commodity *c,
|
||||
gnc_commodity *currency,
|
||||
Timespec t)
|
||||
gnc_pricedb_lookup_latest_before_t64 (GNCPriceDB *db,
|
||||
gnc_commodity *c,
|
||||
gnc_commodity *currency,
|
||||
time64 t)
|
||||
{
|
||||
GList *price_list;
|
||||
GNCPrice *current_price = NULL;
|
||||
/* GNCPrice *next_price = NULL;
|
||||
GNCPrice *result = NULL;*/
|
||||
GList *item = NULL;
|
||||
Timespec price_time;
|
||||
time64 price_time;
|
||||
|
||||
if (!db || !c || !currency) return NULL;
|
||||
ENTER ("db=%p commodity=%p currency=%p", db, c, currency);
|
||||
@ -2488,12 +2431,12 @@ gnc_pricedb_lookup_latest_before (GNCPriceDB *db,
|
||||
item = price_list;
|
||||
do
|
||||
{
|
||||
price_time = gnc_price_get_time (item->data);
|
||||
if (timespec_cmp(&price_time, &t) <= 0)
|
||||
price_time = gnc_price_get_time64 (item->data);
|
||||
if (price_time <= t)
|
||||
current_price = item->data;
|
||||
item = item->next;
|
||||
}
|
||||
while (timespec_cmp(&price_time, &t) > 0 && item);
|
||||
while (price_time > t && item);
|
||||
gnc_price_ref(current_price);
|
||||
g_list_free (price_list);
|
||||
LEAVE (" ");
|
||||
@ -2674,11 +2617,11 @@ gnc_pricedb_convert_balance_latest_price(GNCPriceDB *pdb,
|
||||
}
|
||||
|
||||
gnc_numeric
|
||||
gnc_pricedb_convert_balance_nearest_price(GNCPriceDB *pdb,
|
||||
gnc_numeric balance,
|
||||
const gnc_commodity *balance_currency,
|
||||
const gnc_commodity *new_currency,
|
||||
time64 t)
|
||||
gnc_pricedb_convert_balance_nearest_price_t64(GNCPriceDB *pdb,
|
||||
gnc_numeric balance,
|
||||
const gnc_commodity *balance_currency,
|
||||
const gnc_commodity *new_currency,
|
||||
time64 t)
|
||||
{
|
||||
gnc_numeric new_value;
|
||||
|
||||
@ -3154,7 +3097,7 @@ price_printable(gpointer obj)
|
||||
#endif
|
||||
|
||||
val = gnc_numeric_to_string (pr->value);
|
||||
da = qof_print_date (pr->tmspec.tv_sec);
|
||||
da = qof_print_date (pr->tmspec);
|
||||
|
||||
commodity = gnc_price_get_commodity(pr);
|
||||
currency = gnc_price_get_currency(pr);
|
||||
|
@ -238,8 +238,7 @@ void gnc_price_commit_edit (GNCPrice *p);
|
||||
|
||||
void gnc_price_set_commodity(GNCPrice *p, gnc_commodity *c);
|
||||
void gnc_price_set_currency(GNCPrice *p, gnc_commodity *c);
|
||||
void gnc_price_set_time(GNCPrice *p, Timespec t);
|
||||
void gnc_price_set_time64(GNCPrice *p, time64 t64);
|
||||
void gnc_price_set_time64(GNCPrice *p, time64 t);
|
||||
void gnc_price_set_source(GNCPrice *p, PriceSource source);
|
||||
void gnc_price_set_source_string(GNCPrice *p, const char* s);
|
||||
void gnc_price_set_typestr(GNCPrice *p, const char* type);
|
||||
@ -257,7 +256,6 @@ void gnc_price_set_value(GNCPrice *p, gnc_numeric value);
|
||||
gnc_commodity * gnc_price_get_commodity(const GNCPrice *p);
|
||||
/*@ dependent @*/
|
||||
gnc_commodity * gnc_price_get_currency(const GNCPrice *p);
|
||||
Timespec gnc_price_get_time(const GNCPrice *p);
|
||||
time64 gnc_price_get_time64(const GNCPrice *p);
|
||||
PriceSource gnc_price_get_source(const GNCPrice *p);
|
||||
const char * gnc_price_get_source_string(const GNCPrice *p);
|
||||
@ -406,7 +404,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);
|
||||
|
||||
@ -463,21 +461,21 @@ PriceList * gnc_pricedb_get_prices(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency);
|
||||
|
||||
/** @brief Find the price between two commodities at a timespec.
|
||||
/** @brief Find the price between two commodities at a time64.
|
||||
*
|
||||
* The returned GNCPrice may be in either direction so check to ensure that its
|
||||
* value is correctly applied.
|
||||
* @param db The pricedb
|
||||
* @param commodity The first commodity
|
||||
* @param currency The second commodity
|
||||
* @param t The timespec at which to retrieve the price.
|
||||
* @param t The time64 at which to retrieve the price.
|
||||
* @return A GNCPrice or NULL if none matches.
|
||||
*/
|
||||
/* NOT USED */
|
||||
GNCPrice * gnc_pricedb_lookup_at_time(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t);
|
||||
GNCPrice * gnc_pricedb_lookup_at_time64(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
time64 t);
|
||||
|
||||
/** @brief Return the price between the two commodities on the indicated
|
||||
* day. Note that the notion of day might be distorted by changes in timezone.
|
||||
@ -491,15 +489,10 @@ GNCPrice * gnc_pricedb_lookup_at_time(GNCPriceDB *db,
|
||||
* according to the local timezone.
|
||||
* @return A GNCPrice or NULL on failure.
|
||||
*/
|
||||
GNCPrice * gnc_pricedb_lookup_day(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t);
|
||||
|
||||
GNCPrice * gnc_pricedb_lookup_day_t64(GNCPriceDB *db,
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
time64 t64);
|
||||
const gnc_commodity *commodity,
|
||||
const gnc_commodity *currency,
|
||||
time64 t);
|
||||
|
||||
/** @brief Return the price between the two commoditiesz nearest to the given
|
||||
* time.
|
||||
@ -512,15 +505,10 @@ GNCPrice * gnc_pricedb_lookup_day_t64(GNCPriceDB *db,
|
||||
* @param t The time nearest to which the returned price should be.
|
||||
* @return A GNCPrice or NULL if no prices exist between the two commodities.
|
||||
*/
|
||||
GNCPrice * gnc_pricedb_lookup_nearest_in_time(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
Timespec t);
|
||||
|
||||
GNCPrice * gnc_pricedb_lookup_nearest_in_time64(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
time64 t);
|
||||
const gnc_commodity *c,
|
||||
const gnc_commodity *currency,
|
||||
time64 t);
|
||||
|
||||
/** @brief Return the price nearest in time to that given between the given
|
||||
* commodity and every other.
|
||||
@ -534,12 +522,9 @@ GNCPrice * gnc_pricedb_lookup_nearest_in_time64(GNCPriceDB *db,
|
||||
* @return A PriceList of prices for each commodity pair found or NULL if none
|
||||
* are.
|
||||
*/
|
||||
PriceList * gnc_pricedb_lookup_nearest_in_time_any_currency(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
Timespec t);
|
||||
PriceList * gnc_pricedb_lookup_nearest_in_time_any_currency_t64(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
time64 t64);
|
||||
time64 t);
|
||||
|
||||
/** @brief Return the latest price between the given commodities before the
|
||||
* given time.
|
||||
@ -553,10 +538,10 @@ PriceList * gnc_pricedb_lookup_nearest_in_time_any_currency_t64(GNCPriceDB *db,
|
||||
* @return A GNCPrice or NULL if no prices are found before t.
|
||||
*/
|
||||
/* NOT USED, but see bug 743753 */
|
||||
GNCPrice * gnc_pricedb_lookup_latest_before(GNCPriceDB *db,
|
||||
gnc_commodity *c,
|
||||
gnc_commodity *currency,
|
||||
Timespec t);
|
||||
GNCPrice * gnc_pricedb_lookup_latest_before_t64(GNCPriceDB *db,
|
||||
gnc_commodity *c,
|
||||
gnc_commodity *currency,
|
||||
time64 t);
|
||||
|
||||
/** @brief Return the latest price between the given commodity and any other
|
||||
* before the given time.
|
||||
@ -569,9 +554,9 @@ GNCPrice * gnc_pricedb_lookup_latest_before(GNCPriceDB *db,
|
||||
* @return A PriceList of prices for each commodity found or NULL if none are.
|
||||
*/
|
||||
/* NOT USED, but see bug 743753 */
|
||||
PriceList * gnc_pricedb_lookup_latest_before_any_currency(GNCPriceDB *db,
|
||||
PriceList * gnc_pricedb_lookup_latest_before_any_currency_t64(GNCPriceDB *db,
|
||||
const gnc_commodity *c,
|
||||
Timespec t);
|
||||
time64 t);
|
||||
|
||||
|
||||
/** @brief Convert a balance from one currency to another using the most recent
|
||||
@ -600,11 +585,11 @@ gnc_pricedb_convert_balance_latest_price(GNCPriceDB *pdb,
|
||||
* @return A new balance or gnc_numeric_zero if no price is available.
|
||||
*/
|
||||
gnc_numeric
|
||||
gnc_pricedb_convert_balance_nearest_price(GNCPriceDB *pdb,
|
||||
gnc_numeric balance,
|
||||
const gnc_commodity *balance_currency,
|
||||
const gnc_commodity *new_currency,
|
||||
time64 t);
|
||||
gnc_pricedb_convert_balance_nearest_price_t64(GNCPriceDB *pdb,
|
||||
gnc_numeric balance,
|
||||
const gnc_commodity *balance_currency,
|
||||
const gnc_commodity *new_currency,
|
||||
time64 t);
|
||||
|
||||
typedef gboolean (*GncPriceForeachFunc)(GNCPrice *p, gpointer user_data);
|
||||
|
||||
|
@ -753,15 +753,18 @@ gboolean gncBillTermIsDirty (const GncBillTerm *term)
|
||||
*
|
||||
*/
|
||||
static void
|
||||
compute_monthyear (const GncBillTerm *term, Timespec post_date,
|
||||
compute_monthyear (const GncBillTerm *term, time64 post_date,
|
||||
int *month, int *year)
|
||||
{
|
||||
int iday, imonth, iyear;
|
||||
struct tm tm;
|
||||
int cutoff = term->cutoff;
|
||||
|
||||
g_return_if_fail (term->type == GNC_TERM_TYPE_PROXIMO);
|
||||
|
||||
gnc_timespec2dmy (post_date, &iday, &imonth, &iyear);
|
||||
gnc_localtime_r (&post_date, &tm);
|
||||
iday = tm.tm_mday;
|
||||
imonth = tm.tm_mon + 1;
|
||||
iyear = tm.tm_year + 1900;
|
||||
|
||||
if (cutoff <= 0)
|
||||
cutoff += gnc_date_get_last_mday (imonth - 1, iyear);
|
||||
@ -798,23 +801,23 @@ compute_monthyear (const GncBillTerm *term, Timespec 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, &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;
|
||||
@ -823,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 */
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,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, ts_pass, 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);
|
||||
|
@ -101,7 +101,7 @@ GncInvoice *gncInvoiceCopy (const GncInvoice *other_invoice);
|
||||
void gncInvoiceSetID (GncInvoice *invoice, const char *id);
|
||||
void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner);
|
||||
/** Set the DateOpened using a GDate argument. (Note: Internally this stores
|
||||
the date in a time64 as created through timespecCanonicalDayTime()). */
|
||||
the date in a time64 as created through time64CanonicalDayTime()). */
|
||||
void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date);
|
||||
void gncInvoiceSetDateOpened (GncInvoice *invoice, time64 date);
|
||||
void gncInvoiceSetDatePosted (GncInvoice *invoice, time64 date);
|
||||
@ -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.
|
||||
*/
|
||||
|
@ -257,7 +257,7 @@ gnc_order_class_init (GncOrderClass *klass)
|
||||
g_param_spec_boxed("date-opened",
|
||||
"Date Opened",
|
||||
"The date the order was opened.",
|
||||
GNC_TYPE_TIMESPEC,
|
||||
GNC_TYPE_TIME64,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
@ -266,7 +266,7 @@ gnc_order_class_init (GncOrderClass *klass)
|
||||
g_param_spec_boxed("date-closed",
|
||||
"Date Closed",
|
||||
"The date the order was closed.",
|
||||
GNC_TYPE_TIMESPEC,
|
||||
GNC_TYPE_TIME64,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property
|
||||
|
@ -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, Timespec 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;
|
||||
@ -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 */
|
||||
@ -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, Timespec 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;
|
||||
|
@ -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, Timespec 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, Timespec 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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -261,7 +261,7 @@ gvalue_from_kvp_value (const KvpValue *kval)
|
||||
{
|
||||
GValue *val;
|
||||
gnc_numeric num;
|
||||
Timespec tm;
|
||||
Time64 tm;
|
||||
GDate gdate;
|
||||
|
||||
if (kval == NULL) return NULL;
|
||||
@ -290,9 +290,9 @@ gvalue_from_kvp_value (const KvpValue *kval)
|
||||
g_value_init (val, GNC_TYPE_GUID);
|
||||
g_value_set_boxed (val, kval->get<GncGUID*>());
|
||||
break;
|
||||
case KvpValue::Type::TIMESPEC:
|
||||
g_value_init (val, GNC_TYPE_TIMESPEC);
|
||||
tm = kval->get<Timespec>();
|
||||
case KvpValue::Type::TIME64:
|
||||
g_value_init (val, GNC_TYPE_TIME64);
|
||||
tm = kval->get<Time64>();
|
||||
g_value_set_boxed (val, &tm);
|
||||
break;
|
||||
case KvpValue::Type::GDATE:
|
||||
@ -357,8 +357,8 @@ kvp_value_from_gvalue (const GValue *gval)
|
||||
if (boxed != nullptr)
|
||||
val = new KvpValue(guid_copy(static_cast<GncGUID*>(boxed)));
|
||||
}
|
||||
else if (type == GNC_TYPE_TIMESPEC)
|
||||
val = new KvpValue(*(Timespec*)g_value_get_boxed (gval));
|
||||
else if (type == GNC_TYPE_TIME64)
|
||||
val = new KvpValue(*(Time64*)g_value_get_boxed (gval));
|
||||
else if (type == G_TYPE_DATE)
|
||||
val = new KvpValue(*(GDate*)g_value_get_boxed (gval));
|
||||
else if (type == GNC_TYPE_VALUE_LIST)
|
||||
|
@ -85,8 +85,8 @@ KvpValueImpl::get_type() const noexcept
|
||||
return KvpValue::Type::STRING;
|
||||
else if (datastore.type() == typeid(GncGUID *))
|
||||
return KvpValue::Type::GUID;
|
||||
else if (datastore.type() == typeid(Timespec))
|
||||
return KvpValue::Type::TIMESPEC;
|
||||
else if (datastore.type() == typeid(Time64))
|
||||
return KvpValue::Type::TIME64;
|
||||
else if (datastore.type() == typeid(GList *))
|
||||
return KvpValue::Type::GLIST;
|
||||
else if (datastore.type() == typeid(KvpFrameImpl *))
|
||||
@ -155,11 +155,11 @@ struct to_string_visitor : boost::static_visitor<void>
|
||||
output << ")";
|
||||
}
|
||||
|
||||
void operator()(Timespec val)
|
||||
void operator()(Time64 val)
|
||||
{
|
||||
char tmp1[40] {};
|
||||
gnc_timespec_to_iso8601_buff (val, tmp1);
|
||||
output << tmp1 << " (timespec)";
|
||||
char tmp1[MAX_DATE_LENGTH + 1] {};
|
||||
gnc_time64_to_iso8601_buff (val.t, tmp1);
|
||||
output << tmp1 << " (time64)";
|
||||
}
|
||||
|
||||
void operator()(gnc_numeric val)
|
||||
@ -301,9 +301,9 @@ template <> int compare_visitor::operator()(GncGUID * const & one, GncGUID * con
|
||||
{
|
||||
return guid_compare(one, two);
|
||||
}
|
||||
template <> int compare_visitor::operator()(Timespec const & one, Timespec const & two) const
|
||||
template <> int compare_visitor::operator()(Time64 const & one, Time64 const & two) const
|
||||
{
|
||||
return timespec_cmp(&one,&two);
|
||||
return one.t < two.t ? -1 : one.t > two.t ? 1 : 0;
|
||||
}
|
||||
template <> int compare_visitor::operator()(GDate const & one, GDate const & two) const
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ struct KvpValueImpl
|
||||
NUMERIC, /**< QOF_TYPE_NUMERIC */
|
||||
STRING, /**< QOF_TYPE_STRING gchar* */
|
||||
GUID, /**< QOF_TYPE_GUID */
|
||||
TIMESPEC, /**< QOF_TYPE_DATE */
|
||||
TIME64, /**< QOF_TYPE_DATE */
|
||||
PLACEHOLDER_DONT_USE, /* Replaces KVP_TYPE_BINARY */
|
||||
GLIST, /**< no QOF equivalent. */
|
||||
FRAME, /**< no QOF equivalent. */
|
||||
@ -156,7 +156,7 @@ struct KvpValueImpl
|
||||
gnc_numeric,
|
||||
const char*,
|
||||
GncGUID *,
|
||||
Timespec,
|
||||
Time64,
|
||||
GList *,
|
||||
KvpFrame *,
|
||||
GDate> datastore;
|
||||
|
@ -72,7 +72,7 @@ Use: An enumerated identifier indicating how often books are supposed
|
||||
|
||||
\verbatim
|
||||
Name: /book/close-date
|
||||
Type: Timespec
|
||||
Type: Time64
|
||||
Entities: Book
|
||||
Use: The posted closing date of this book. This book only contains
|
||||
transactions whose posted date is earlier than this closing date.
|
||||
@ -98,7 +98,7 @@ Use: The GUID of the book for which this transaction represents the
|
||||
|
||||
\verbatim
|
||||
Name: /book/log-date
|
||||
Type: Timespec
|
||||
Type: Time64
|
||||
Entities: Book
|
||||
Use: A log of the date which the user performed the closing of the book.
|
||||
\endverbatim
|
||||
@ -131,7 +131,7 @@ Use: User-suplied notes for the book. The user can set this to any value
|
||||
|
||||
\verbatim
|
||||
Name: /book/open-date
|
||||
Type: Timespec
|
||||
Type: Time64
|
||||
Entities: Book
|
||||
Use: The posted opening date of this book. This book only contains transactions
|
||||
whose posted date is later than this closing date.
|
||||
@ -254,7 +254,7 @@ Use: When this appears in an account, then it contains the guid of
|
||||
|
||||
\verbatim
|
||||
Name: /gemini/<type>/date
|
||||
Type: timespec
|
||||
Type: time64
|
||||
Entities: Account, Book
|
||||
Use: date that the copy was created.
|
||||
\endverbatim
|
||||
@ -293,7 +293,7 @@ Use: Country code of the bank of HBCI account
|
||||
|
||||
\verbatim
|
||||
Name: /hbci/trans-retrieval
|
||||
Type: Timespec
|
||||
Type: Time64
|
||||
Entities: Account
|
||||
Use: Time of the last statement retrieval through HBCI for this
|
||||
specific account
|
||||
@ -577,7 +577,7 @@ Use: A user-supplied title for the lot. The user can set this to
|
||||
|
||||
\verbatim
|
||||
Name: trans-date-due
|
||||
Type: Timespec
|
||||
Type: Time64
|
||||
Entities: Transaction
|
||||
Use: Accounts/Receivable, Accounts/Payable Due Date.
|
||||
\endverbatim
|
||||
|
@ -51,7 +51,7 @@ void qof_instance_set_slots (QofInstance *, KvpFrame *);
|
||||
* used for comparing version in local memory to that in remote
|
||||
* server.
|
||||
*/
|
||||
void qof_instance_set_last_update (QofInstance *inst, Timespec ts);
|
||||
void qof_instance_set_last_update (QofInstance *inst, time64 time);
|
||||
|
||||
/** Set the dirty flag of just the instance. Don't modify the
|
||||
* collection flag at all. */
|
||||
@ -144,7 +144,7 @@ int qof_instance_compare_kvp (const QofInstance *a, const QofInstance *b);
|
||||
/** Returns a g_strdup'd string which must be g_freed. */
|
||||
char* qof_instance_kvp_as_string (const QofInstance *inst);
|
||||
void qof_instance_kvp_add_guid (const QofInstance *inst, const char* path,
|
||||
const Timespec time, const char* key,
|
||||
time64 time, const char* key,
|
||||
const GncGUID *guid);
|
||||
void qof_instance_kvp_remove_guid (const QofInstance *inst, const char *path,
|
||||
const char* key, const GncGUID *guid);
|
||||
|
@ -86,7 +86,7 @@ typedef struct QofInstancePrivate
|
||||
* SQL backend, this field is reserved for SQL use, to compare
|
||||
* the version in local memory to the remote, server version.
|
||||
*/
|
||||
Timespec last_update;
|
||||
time64 last_update;
|
||||
|
||||
/* Keep track of nesting level of begin/end edit calls */
|
||||
int editlevel;
|
||||
@ -264,8 +264,7 @@ qof_instance_init (QofInstance *inst)
|
||||
priv = GET_PRIVATE(inst);
|
||||
priv->book = NULL;
|
||||
inst->kvp_data = new KvpFrame;
|
||||
priv->last_update.tv_sec = 0;
|
||||
priv->last_update.tv_nsec = -1;
|
||||
priv->last_update = 0;
|
||||
priv->editlevel = 0;
|
||||
priv->do_free = FALSE;
|
||||
priv->dirty = FALSE;
|
||||
@ -415,7 +414,7 @@ qof_instance_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
QofInstance *inst;
|
||||
Timespec *ts;
|
||||
Time64 t;
|
||||
|
||||
g_return_if_fail(QOF_IS_INSTANCE(object));
|
||||
|
||||
@ -435,8 +434,8 @@ qof_instance_set_property (GObject *object,
|
||||
static_cast<QofBook*>(g_value_get_object(value)));
|
||||
break;
|
||||
case PROP_LAST_UPDATE:
|
||||
ts = static_cast<Timespec*>(g_value_get_pointer(value));
|
||||
qof_instance_set_last_update(inst, *ts);
|
||||
t = *(static_cast<Time64*>(g_value_get_pointer(value)));
|
||||
qof_instance_set_last_update(inst, t.t);
|
||||
break;
|
||||
case PROP_DESTROYING:
|
||||
qof_instance_set_destroying(inst, g_value_get_boolean(value));
|
||||
@ -598,10 +597,10 @@ qof_instance_set_slots (QofInstance *inst, KvpFrame *frm)
|
||||
}
|
||||
|
||||
void
|
||||
qof_instance_set_last_update (QofInstance *inst, Timespec ts)
|
||||
qof_instance_set_last_update (QofInstance *inst, time64 t)
|
||||
{
|
||||
if (!inst) return;
|
||||
GET_PRIVATE(inst)->last_update = ts;
|
||||
GET_PRIVATE(inst)->last_update = t;
|
||||
}
|
||||
|
||||
gint
|
||||
@ -640,11 +639,8 @@ qof_instance_version_cmp (const QofInstance *left, const QofInstance *right)
|
||||
|
||||
lpriv = GET_PRIVATE(left);
|
||||
rpriv = GET_PRIVATE(right);
|
||||
if (lpriv->last_update.tv_sec < rpriv->last_update.tv_sec) return -1;
|
||||
if (lpriv->last_update.tv_sec > rpriv->last_update.tv_sec) return +1;
|
||||
if (lpriv->last_update.tv_nsec < rpriv->last_update.tv_nsec) return -1;
|
||||
if (lpriv->last_update.tv_nsec > rpriv->last_update.tv_nsec) return +1;
|
||||
return 0;
|
||||
return lpriv->last_update < rpriv->last_update ? -1 :
|
||||
lpriv->last_update > rpriv->last_update ? 1 : 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -1138,14 +1134,15 @@ qof_instance_kvp_as_string (const QofInstance *inst)
|
||||
|
||||
void
|
||||
qof_instance_kvp_add_guid (const QofInstance *inst, const char* path,
|
||||
const Timespec time, const char *key,
|
||||
time64 time, const char *key,
|
||||
const GncGUID *guid)
|
||||
{
|
||||
g_return_if_fail (inst->kvp_data != NULL);
|
||||
|
||||
auto container = new KvpFrame;
|
||||
Time64 t{time};
|
||||
container->set({key}, new KvpValue(const_cast<GncGUID*>(guid)));
|
||||
container->set({"date"}, new KvpValue(time));
|
||||
container->set({"date"}, new KvpValue(t));
|
||||
delete inst->kvp_data->set_path({path}, new KvpValue(container));
|
||||
}
|
||||
|
||||
|
@ -1827,9 +1827,12 @@ qof_query_printValueForParam (QofQueryPredData *pd, GString * gs)
|
||||
if (!g_strcmp0 (pd->type_name, QOF_TYPE_DATE))
|
||||
{
|
||||
query_date_t pdata = (query_date_t) pd;
|
||||
char datebuff[MAX_DATE_LENGTH + 1];
|
||||
memset (datebuff, 0, sizeof(datebuff));
|
||||
qof_print_date_buff (datebuff, sizeof(datebuff), pdata->date);
|
||||
g_string_append_printf (gs, " Match type %s",
|
||||
qof_query_printDateMatch (pdata->options));
|
||||
g_string_append_printf (gs, " query_date: %s", gnc_print_date ({pdata->date, 0}));
|
||||
g_string_append_printf (gs, " query_date: %s", datebuff);
|
||||
return;
|
||||
}
|
||||
if (!g_strcmp0 (pd->type_name, QOF_TYPE_CHAR))
|
||||
|
@ -450,7 +450,7 @@ date_to_string (gpointer object, QofParam *getter)
|
||||
time64 tt = ((query_date_getter)getter->param_getfcn)(object, getter);
|
||||
|
||||
if (tt != INT64_MAX)
|
||||
return g_strdup (gnc_print_date ({tt, 0}));
|
||||
return qof_print_date (tt);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -157,20 +157,6 @@ kvp_type_excluded (KvpValue::Type kvp_type)
|
||||
|
||||
static gboolean zero_nsec = FALSE;
|
||||
|
||||
void
|
||||
random_timespec_zero_nsec (gboolean zero_nsec_in)
|
||||
{
|
||||
zero_nsec = zero_nsec_in;
|
||||
}
|
||||
|
||||
static gboolean usec_resolution = FALSE;
|
||||
|
||||
void
|
||||
random_timespec_usec_resolution (gboolean usec_resolution_in)
|
||||
{
|
||||
usec_resolution = usec_resolution_in;
|
||||
}
|
||||
|
||||
/* ========================================================== */
|
||||
|
||||
static inline gboolean
|
||||
@ -236,20 +222,6 @@ get_random_time (void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Timespec*
|
||||
get_random_timespec(void)
|
||||
{
|
||||
Timespec *ret;
|
||||
|
||||
ret = g_new0(Timespec, 1);
|
||||
|
||||
while (ret->tv_sec <= 0)
|
||||
ret->tv_sec = rand();
|
||||
|
||||
ret->tv_nsec = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
GncGUID*
|
||||
get_random_guid(void)
|
||||
{
|
||||
@ -324,11 +296,10 @@ get_random_kvp_value_depth (int type, gint depth)
|
||||
}
|
||||
break;
|
||||
|
||||
case KvpValue::Type::TIMESPEC:
|
||||
case KvpValue::Type::TIME64:
|
||||
{
|
||||
Timespec *ts = get_random_timespec();
|
||||
ret = new KvpValue(*ts);
|
||||
g_free(ts);
|
||||
time64 t = get_random_time();
|
||||
ret = new KvpValue(t);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -648,7 +619,7 @@ make_random_changes_to_commodity_table (gnc_commodity_table *table)
|
||||
void
|
||||
make_random_changes_to_price (QofBook *book, GNCPrice *p)
|
||||
{
|
||||
Timespec *ts;
|
||||
time64 time;
|
||||
PriceSource ps;
|
||||
char *string;
|
||||
gnc_commodity *c;
|
||||
@ -663,9 +634,8 @@ make_random_changes_to_price (QofBook *book, GNCPrice *p)
|
||||
c = get_random_commodity (book);
|
||||
gnc_price_set_currency (p, c);
|
||||
|
||||
ts = get_random_timespec ();
|
||||
gnc_price_set_time (p, *ts);
|
||||
g_free (ts);
|
||||
time = get_random_time ();
|
||||
gnc_price_set_time64 (p, time);
|
||||
|
||||
ps = (PriceSource)get_random_int_in_range((int)PRICE_SOURCE_EDIT_DLG,
|
||||
(int)PRICE_SOURCE_INVALID);
|
||||
@ -1269,7 +1239,7 @@ get_random_split(QofBook *book, Account *acct, Transaction *trn)
|
||||
const gchar *str;
|
||||
gnc_commodity *com;
|
||||
int scu, denom;
|
||||
Timespec *ts;
|
||||
time64 time;
|
||||
|
||||
com = xaccTransGetCurrency (trn);
|
||||
scu = gnc_commodity_get_fraction(com);
|
||||
@ -1283,9 +1253,8 @@ get_random_split(QofBook *book, Account *acct, Transaction *trn)
|
||||
|
||||
xaccSplitSetReconcile(ret, possible_chars[get_random_int_in_range(0, 3)]);
|
||||
|
||||
ts = get_random_timespec();
|
||||
xaccSplitSetDateReconciledTS(ret, ts);
|
||||
g_free(ts);
|
||||
time = get_random_time();
|
||||
xaccSplitSetDateReconciledSecs (ret, time);
|
||||
|
||||
/* Split must be in an account before we can set an amount */
|
||||
/* and in a transaction before it can be added to an account. */
|
||||
@ -1366,7 +1335,7 @@ void
|
||||
make_random_changes_to_split (Split *split)
|
||||
{
|
||||
Transaction *trans;
|
||||
Timespec *ts;
|
||||
time64 time;
|
||||
|
||||
g_return_if_fail (split);
|
||||
|
||||
@ -1379,9 +1348,8 @@ make_random_changes_to_split (Split *split)
|
||||
|
||||
xaccSplitSetReconcile (split, possible_chars[get_random_int_in_range(0, 3)]);
|
||||
|
||||
ts = get_random_timespec();
|
||||
xaccSplitSetDateReconciledTS (split, ts);
|
||||
g_free(ts);
|
||||
time = get_random_time();
|
||||
xaccSplitSetDateReconciledSecs (split, time);
|
||||
|
||||
qof_instance_set_slots (QOF_INSTANCE (split), get_random_kvp_frame());
|
||||
|
||||
|
@ -45,10 +45,8 @@ typedef struct KvpValueImpl KvpValue;
|
||||
typedef struct KvpFrameImpl KvpFrame;
|
||||
#define __KVP_FRAME
|
||||
#endif
|
||||
Timespec* get_random_timespec(void);
|
||||
|
||||
time64 get_random_time(void);
|
||||
void random_timespec_zero_nsec (gboolean zero_nsec);
|
||||
void random_timespec_usec_resolution (gboolean usec_resolution);
|
||||
|
||||
KvpValue* get_random_kvp_value(int type);
|
||||
|
||||
|
@ -26,7 +26,6 @@ add_dependencies(check test-link)
|
||||
|
||||
add_engine_test(test-load-engine test-load-engine.c)
|
||||
add_engine_test(test-guid test-guid.cpp)
|
||||
add_engine_test(test-date test-date.cpp)
|
||||
add_engine_test(test-object test-object.c)
|
||||
add_engine_test(test-commodities test-commodities.cpp)
|
||||
|
||||
@ -271,7 +270,6 @@ set(test_engine_SOURCES_DIST
|
||||
test-business.c
|
||||
test-commodities.cpp
|
||||
test-customer.c
|
||||
test-date.cpp
|
||||
test-employee.c
|
||||
test-engine-kvp-properties.c
|
||||
test-engine.c
|
||||
|
@ -1,417 +0,0 @@
|
||||
/*
|
||||
* -- fix borken timezone test -- linas May 2004
|
||||
*/
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <config.h>
|
||||
#include <ctype.h>
|
||||
#include <glib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "gnc-date.h"
|
||||
#include "gnc-module.h"
|
||||
#include "test-stuff.h"
|
||||
#include "test-engine-stuff.h"
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_time (Timespec ts, gboolean always_print)
|
||||
{
|
||||
Timespec ts_2;
|
||||
char str[128];
|
||||
gboolean ok;
|
||||
|
||||
ts.tv_nsec = MIN (ts.tv_nsec, 999999999);
|
||||
ts.tv_nsec /= 1000;
|
||||
ts.tv_nsec *= 1000;
|
||||
|
||||
gnc_timespec_to_iso8601_buff (ts, str);
|
||||
|
||||
/* The time, in seconds, everywhere on the planet, is always
|
||||
* the same, and is independent of location. In particular,
|
||||
* the time, in seconds, is identical to the local time in
|
||||
* Greenwich (GMT).
|
||||
*/
|
||||
ts_2 = {gnc_iso8601_to_time64_gmt (str), 0};
|
||||
|
||||
ok = timespec_equal (&ts, &ts_2);
|
||||
|
||||
if (!ok || always_print)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"\n%" G_GINT64_FORMAT ":%ld -> %s ->\n"
|
||||
"\t%" G_GINT64_FORMAT ":%ld"
|
||||
" (diff of %" G_GINT64_FORMAT " secs %ld nsecs)\n",
|
||||
ts.tv_sec, ts.tv_nsec, str,
|
||||
ts_2.tv_sec, ts_2.tv_nsec,
|
||||
ts.tv_sec - ts_2.tv_sec, ts.tv_nsec - ts_2.tv_nsec);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
failure ("timespec to iso8601 string conversion failed");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
success ("timespec to iso8601 string conversion passes");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_conversion (const char * str, Timespec expected_ts)
|
||||
{
|
||||
Timespec ts;
|
||||
int day, month, year;
|
||||
GDate d1, d2;
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt (str), 0};
|
||||
|
||||
// We test the conversion to GDate against the timespec2dmy
|
||||
// conversion, and also the conversion back to timespec and again
|
||||
// to GDate so that it is still the original GDate
|
||||
gnc_timespec2dmy(ts, &day, &month, &year);
|
||||
d1 = timespec_to_gdate(ts);
|
||||
d2 = timespec_to_gdate(gdate_to_timespec(d1));
|
||||
if ((g_date_compare(&d1, &d2) != 0)
|
||||
|| (g_date_get_day(&d1) != day)
|
||||
|| (g_date_get_month(&d1) != month)
|
||||
|| (g_date_get_year(&d1) != year))
|
||||
{
|
||||
fprintf (stderr,
|
||||
"\nmis-converted \"%s\" to GDate. "
|
||||
"Got d1(Y-M-D) = %i-%i-%i, d2(Y-M-D) = %i-%i-%i\n",
|
||||
str, year, month, day,
|
||||
g_date_get_year(&d2), g_date_get_month(&d2), g_date_get_day(&d2));
|
||||
failure ("misconverted timespec");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((expected_ts.tv_sec != ts.tv_sec) || (expected_ts.tv_nsec != ts.tv_nsec))
|
||||
{
|
||||
fprintf (stderr,
|
||||
"\nmis-converted \"%s\" to %" G_GUINT64_FORMAT ".%09ld seconds\n"
|
||||
"\twas expecting %" G_GUINT64_FORMAT ".%09ld seconds\n",
|
||||
str, ts.tv_sec, ts.tv_nsec,
|
||||
expected_ts.tv_sec, expected_ts.tv_nsec);
|
||||
failure ("misconverted timespec");
|
||||
return FALSE;
|
||||
}
|
||||
success ("good conversion");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
run_test (void)
|
||||
{
|
||||
Timespec ts;
|
||||
int i;
|
||||
gboolean do_print = FALSE;
|
||||
|
||||
/* Now leaving the 60's:
|
||||
*
|
||||
* Black Panthers
|
||||
* Weather Underground
|
||||
* Kent State
|
||||
* Evacuation of Vietnam
|
||||
* Impeachment
|
||||
* Gas Crisis
|
||||
* New York Garbage Crisis
|
||||
* Stagflation
|
||||
* Delapidated Bicentennial
|
||||
* Sex Pistols
|
||||
* Punk Rock
|
||||
*
|
||||
* Of course, anything had to be better than the miserable 70's,
|
||||
* which explains why Reagan was elected. Food for thought.
|
||||
*/
|
||||
ts.tv_sec = 10 * 365 * 24 * 3600 + 2 * 24 * 3600;
|
||||
ts.tv_nsec = 0;
|
||||
check_conversion ("1979-12-31 15:00:00.000000 -0900", ts);
|
||||
check_conversion ("1979-12-31 16:00:00.000000 -0800", ts);
|
||||
check_conversion ("1979-12-31 17:00:00.000000 -0700", ts);
|
||||
check_conversion ("1979-12-31 18:00:00.000000 -0600", ts);
|
||||
check_conversion ("1979-12-31 19:00:00.000000 -0500", ts);
|
||||
check_conversion ("1979-12-31 20:00:00.000000 -0400", ts);
|
||||
check_conversion ("1979-12-31 21:00:00.000000 -0300", ts);
|
||||
check_conversion ("1979-12-31 22:00:00.000000 -0200", ts);
|
||||
check_conversion ("1979-12-31 23:00:00.000000 -0100", ts);
|
||||
|
||||
check_conversion ("1980-01-01 00:00:00.000000 -0000", ts);
|
||||
check_conversion ("1980-01-01 00:00:00.000000 +0000", ts);
|
||||
|
||||
check_conversion ("1980-01-01 01:00:00.000000 +0100", ts);
|
||||
check_conversion ("1980-01-01 02:00:00.000000 +0200", ts);
|
||||
check_conversion ("1980-01-01 03:00:00.000000 +0300", ts);
|
||||
check_conversion ("1980-01-01 04:00:00.000000 +0400", ts);
|
||||
check_conversion ("1980-01-01 05:00:00.000000 +0500", ts);
|
||||
check_conversion ("1980-01-01 06:00:00.000000 +0600", ts);
|
||||
check_conversion ("1980-01-01 07:00:00.000000 +0700", ts);
|
||||
check_conversion ("1980-01-01 08:00:00.000000 +0800", ts);
|
||||
|
||||
/* check minute-offsets as well */
|
||||
check_conversion ("1980-01-01 08:01:00.000000 +0801", ts);
|
||||
check_conversion ("1980-01-01 08:02:00.000000 +0802", ts);
|
||||
check_conversion ("1980-01-01 08:03:00.000000 +0803", ts);
|
||||
check_conversion ("1980-01-01 08:23:00.000000 +0823", ts);
|
||||
check_conversion ("1980-01-01 08:35:00.000000 +0835", ts);
|
||||
check_conversion ("1980-01-01 08:47:00.000000 +0847", ts);
|
||||
check_conversion ("1980-01-01 08:59:00.000000 +0859", ts);
|
||||
|
||||
check_conversion ("1979-12-31 15:01:00.000000 -0859", ts);
|
||||
check_conversion ("1979-12-31 15:02:00.000000 -0858", ts);
|
||||
check_conversion ("1979-12-31 15:03:00.000000 -0857", ts);
|
||||
check_conversion ("1979-12-31 15:23:00.000000 -0837", ts);
|
||||
check_conversion ("1979-12-31 15:45:00.000000 -0815", ts);
|
||||
|
||||
|
||||
/* The 90's */
|
||||
ts.tv_sec = 20 * 365 * 24 * 3600 + 5 * 24 * 3600;
|
||||
ts.tv_nsec = 0;
|
||||
check_conversion ("1989-12-31 15:00:00.000000 -0900", ts);
|
||||
check_conversion ("1989-12-31 16:00:00.000000 -0800", ts);
|
||||
check_conversion ("1989-12-31 17:00:00.000000 -0700", ts);
|
||||
check_conversion ("1989-12-31 18:00:00.000000 -0600", ts);
|
||||
check_conversion ("1989-12-31 19:00:00.000000 -0500", ts);
|
||||
check_conversion ("1989-12-31 20:00:00.000000 -0400", ts);
|
||||
check_conversion ("1989-12-31 21:00:00.000000 -0300", ts);
|
||||
check_conversion ("1989-12-31 22:00:00.000000 -0200", ts);
|
||||
check_conversion ("1989-12-31 23:00:00.000000 -0100", ts);
|
||||
|
||||
check_conversion ("1990-01-01 00:00:00.000000 -0000", ts);
|
||||
check_conversion ("1990-01-01 00:00:00.000000 +0000", ts);
|
||||
|
||||
check_conversion ("1990-01-01 01:00:00.000000 +0100", ts);
|
||||
check_conversion ("1990-01-01 02:00:00.000000 +0200", ts);
|
||||
check_conversion ("1990-01-01 03:00:00.000000 +0300", ts);
|
||||
check_conversion ("1990-01-01 04:00:00.000000 +0400", ts);
|
||||
check_conversion ("1990-01-01 05:00:00.000000 +0500", ts);
|
||||
check_conversion ("1990-01-01 06:00:00.000000 +0600", ts);
|
||||
check_conversion ("1990-01-01 07:00:00.000000 +0700", ts);
|
||||
check_conversion ("1990-01-01 08:00:00.000000 +0800", ts);
|
||||
|
||||
/* check minute-offsets as well */
|
||||
check_conversion ("1990-01-01 08:01:00.000000 +0801", ts);
|
||||
check_conversion ("1990-01-01 08:02:00.000000 +0802", ts);
|
||||
check_conversion ("1990-01-01 08:03:00.000000 +0803", ts);
|
||||
check_conversion ("1990-01-01 08:23:00.000000 +0823", ts);
|
||||
check_conversion ("1990-01-01 08:35:00.000000 +0835", ts);
|
||||
check_conversion ("1990-01-01 08:47:00.000000 +0847", ts);
|
||||
check_conversion ("1990-01-01 08:59:00.000000 +0859", ts);
|
||||
|
||||
check_conversion ("1989-12-31 15:01:00.000000 -0859", ts);
|
||||
check_conversion ("1989-12-31 15:02:00.000000 -0858", ts);
|
||||
check_conversion ("1989-12-31 15:03:00.000000 -0857", ts);
|
||||
check_conversion ("1989-12-31 15:23:00.000000 -0837", ts);
|
||||
check_conversion ("1989-12-31 15:45:00.000000 -0815", ts);
|
||||
|
||||
|
||||
/* The naughties */
|
||||
ts.tv_sec = 30 * 365 * 24 * 3600 + 7 * 24 * 3600;
|
||||
ts.tv_nsec = 0;
|
||||
check_conversion ("1999-12-31 15:00:00.000000 -0900", ts);
|
||||
check_conversion ("1999-12-31 16:00:00.000000 -0800", ts);
|
||||
check_conversion ("1999-12-31 17:00:00.000000 -0700", ts);
|
||||
check_conversion ("1999-12-31 18:00:00.000000 -0600", ts);
|
||||
check_conversion ("1999-12-31 19:00:00.000000 -0500", ts);
|
||||
check_conversion ("1999-12-31 20:00:00.000000 -0400", ts);
|
||||
check_conversion ("1999-12-31 21:00:00.000000 -0300", ts);
|
||||
check_conversion ("1999-12-31 22:00:00.000000 -0200", ts);
|
||||
check_conversion ("1999-12-31 23:00:00.000000 -0100", ts);
|
||||
|
||||
check_conversion ("2000-01-01 00:00:00.000000 -0000", ts);
|
||||
check_conversion ("2000-01-01 00:00:00.000000 +0000", ts);
|
||||
|
||||
check_conversion ("2000-01-01 01:00:00.000000 +0100", ts);
|
||||
check_conversion ("2000-01-01 02:00:00.000000 +0200", ts);
|
||||
check_conversion ("2000-01-01 03:00:00.000000 +0300", ts);
|
||||
check_conversion ("2000-01-01 04:00:00.000000 +0400", ts);
|
||||
check_conversion ("2000-01-01 05:00:00.000000 +0500", ts);
|
||||
check_conversion ("2000-01-01 06:00:00.000000 +0600", ts);
|
||||
check_conversion ("2000-01-01 07:00:00.000000 +0700", ts);
|
||||
check_conversion ("2000-01-01 08:00:00.000000 +0800", ts);
|
||||
|
||||
/* check minute-offsets as well */
|
||||
check_conversion ("2000-01-01 08:01:00.000000 +0801", ts);
|
||||
check_conversion ("2000-01-01 08:02:00.000000 +0802", ts);
|
||||
check_conversion ("2000-01-01 08:03:00.000000 +0803", ts);
|
||||
check_conversion ("2000-01-01 08:23:00.000000 +0823", ts);
|
||||
check_conversion ("2000-01-01 08:35:00.000000 +0835", ts);
|
||||
check_conversion ("2000-01-01 08:47:00.000000 +0847", ts);
|
||||
check_conversion ("2000-01-01 08:59:00.000000 +0859", ts);
|
||||
|
||||
check_conversion ("1999-12-31 15:01:00.000000 -0859", ts);
|
||||
check_conversion ("1999-12-31 15:02:00.000000 -0858", ts);
|
||||
check_conversion ("1999-12-31 15:03:00.000000 -0857", ts);
|
||||
check_conversion ("1999-12-31 15:23:00.000000 -0837", ts);
|
||||
check_conversion ("1999-12-31 15:45:00.000000 -0815", ts);
|
||||
|
||||
|
||||
/* The nows */
|
||||
ts.tv_sec = 35 * 365 * 24 * 3600 + 9 * 24 * 3600;
|
||||
ts.tv_nsec = 0;
|
||||
check_conversion ("2004-12-31 15:00:00.000000 -0900", ts);
|
||||
check_conversion ("2004-12-31 16:00:00.000000 -0800", ts);
|
||||
check_conversion ("2004-12-31 17:00:00.000000 -0700", ts);
|
||||
check_conversion ("2004-12-31 18:00:00.000000 -0600", ts);
|
||||
check_conversion ("2004-12-31 19:00:00.000000 -0500", ts);
|
||||
check_conversion ("2004-12-31 20:00:00.000000 -0400", ts);
|
||||
check_conversion ("2004-12-31 21:00:00.000000 -0300", ts);
|
||||
check_conversion ("2004-12-31 22:00:00.000000 -0200", ts);
|
||||
check_conversion ("2004-12-31 23:00:00.000000 -0100", ts);
|
||||
|
||||
check_conversion ("2005-01-01 00:00:00.000000 -0000", ts);
|
||||
check_conversion ("2005-01-01 00:00:00.000000 +0000", ts);
|
||||
|
||||
check_conversion ("2005-01-01 01:00:00.000000 +0100", ts);
|
||||
check_conversion ("2005-01-01 02:00:00.000000 +0200", ts);
|
||||
check_conversion ("2005-01-01 03:00:00.000000 +0300", ts);
|
||||
check_conversion ("2005-01-01 04:00:00.000000 +0400", ts);
|
||||
check_conversion ("2005-01-01 05:00:00.000000 +0500", ts);
|
||||
check_conversion ("2005-01-01 06:00:00.000000 +0600", ts);
|
||||
check_conversion ("2005-01-01 07:00:00.000000 +0700", ts);
|
||||
check_conversion ("2005-01-01 08:00:00.000000 +0800", ts);
|
||||
|
||||
/* check minute-offsets as well */
|
||||
check_conversion ("2005-01-01 08:01:00.000000 +0801", ts);
|
||||
check_conversion ("2005-01-01 08:02:00.000000 +0802", ts);
|
||||
check_conversion ("2005-01-01 08:03:00.000000 +0803", ts);
|
||||
check_conversion ("2005-01-01 08:23:00.000000 +0823", ts);
|
||||
check_conversion ("2005-01-01 08:35:00.000000 +0835", ts);
|
||||
check_conversion ("2005-01-01 08:47:00.000000 +0847", ts);
|
||||
check_conversion ("2005-01-01 08:59:00.000000 +0859", ts);
|
||||
|
||||
check_conversion ("2004-12-31 15:01:00.000000 -0859", ts);
|
||||
check_conversion ("2004-12-31 15:02:00.000000 -0858", ts);
|
||||
check_conversion ("2004-12-31 15:03:00.000000 -0857", ts);
|
||||
check_conversion ("2004-12-31 15:23:00.000000 -0837", ts);
|
||||
check_conversion ("2004-12-31 15:45:00.000000 -0815", ts);
|
||||
|
||||
|
||||
/* Various leap-year days and near-leap times. */
|
||||
ts = {gnc_iso8601_to_time64_gmt ("1980-02-29 00:00:00.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt ("1979-02-28 00:00:00.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt ("1990-02-28 00:00:00.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt ("2000-02-29 00:00:00.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt ("2004-02-29 00:00:00.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt ("2008-02-29 00:00:00.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt ("2008-02-29 00:01:00.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt ("2008-02-29 02:02:00.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = {gnc_iso8601_to_time64_gmt ("2008-02-28 23:23:23.000000 -0000"), 0};
|
||||
check_time (ts, do_print);
|
||||
|
||||
/* Here's a date ten days after the 2038 rollover that should work
|
||||
if/when we support it. */
|
||||
ts.tv_nsec = 0;
|
||||
ts.tv_sec = (long long int) 0x7fffffff + 3600 * 24 * 10;
|
||||
check_time(ts, do_print);
|
||||
|
||||
/* Various 'special' times. What makes these so special? */
|
||||
ts.tv_sec = 152098136;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1162088421;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 325659000 - 6500;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1143943200;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1603591171;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1738909365;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1603591171;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1143943200 - 1;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1143943200;
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1143943200 + (7 * 60 * 60);
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts.tv_sec = 1143943200 + (8 * 60 * 60);
|
||||
ts.tv_nsec = 0;
|
||||
check_time (ts, do_print);
|
||||
|
||||
ts = *get_random_timespec ();
|
||||
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
ts.tv_sec += 10800;
|
||||
if (!check_time (ts, FALSE))
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 5000; i++)
|
||||
{
|
||||
ts = *get_random_timespec ();
|
||||
|
||||
if (!check_time (ts, FALSE))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
run_test ();
|
||||
|
||||
success ("dates seem to work");
|
||||
|
||||
print_test_results();
|
||||
exit(get_rv());
|
||||
}
|
@ -144,8 +144,8 @@ test_account_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
gchar *online_id_r, *ab_acct_id_r, *ab_bank_code_r;
|
||||
GncGUID *ofx_income_acct = guid_malloc ();
|
||||
GncGUID *ofx_income_acct_r;
|
||||
Timespec trans_retr = timespec_now ();
|
||||
Timespec *trans_retr_r;
|
||||
Time64 trans_retr = {gnc_time(NULL)};
|
||||
Time64 *trans_retr_r;
|
||||
|
||||
xaccAccountBeginEdit (fixture->acct);
|
||||
qof_instance_set (QOF_INSTANCE (fixture->acct),
|
||||
@ -176,7 +176,7 @@ test_account_kvp_properties (Fixture *fixture, gconstpointer pData)
|
||||
g_assert_cmpstr (ab_acct_id, ==, ab_acct_id_r);
|
||||
g_assert_cmpstr (ab_bank_code, ==, ab_bank_code_r);
|
||||
g_assert_cmpint (ab_acct_uid, ==, ab_acct_uid_r);
|
||||
g_assert (timespec_equal (&trans_retr, trans_retr_r));
|
||||
g_assert_cmpint (trans_retr.t, ==, trans_retr_r->t);
|
||||
g_assert (!qof_instance_is_dirty (QOF_INSTANCE (fixture->acct)));
|
||||
}
|
||||
|
||||
|
@ -61,12 +61,12 @@ typedef struct
|
||||
TZOffset off_zulu;
|
||||
TZOffset off_05w;
|
||||
TZOffset off_0840e;
|
||||
Timespec ts0;
|
||||
Timespec ts1;
|
||||
Timespec ts2;
|
||||
Timespec ts3;
|
||||
Timespec ts4;
|
||||
Timespec ts5;
|
||||
time64 t0;
|
||||
time64 t1;
|
||||
time64 t2;
|
||||
time64 t3;
|
||||
time64 t4;
|
||||
time64 t5;
|
||||
} FixtureA;
|
||||
|
||||
static int
|
||||
@ -83,15 +83,15 @@ offset_string (TZOffset tz)
|
||||
|
||||
static void setup (FixtureA *f, gconstpointer pData)
|
||||
{
|
||||
f->ts0 = (Timespec){gnc_time(NULL), 0};
|
||||
f->t0 = gnc_time(NULL);
|
||||
f->off_zulu = (TZOffset){0, 0};
|
||||
f->off_05w = (TZOffset){-5, 0};
|
||||
f->off_0840e = (TZOffset){8, 40};
|
||||
f->ts1 = (Timespec){607009407, 0}; //1989-3-27 13:43:27 Z
|
||||
f->ts2 = (Timespec){1604748079, 0}; //2020-11-7 06:21:19 -05:00
|
||||
f->ts3 = (Timespec){1341398864, 0}; //2012-07-04 19:27:44 +08:40
|
||||
f->ts4 = (Timespec){-261104801, 0}; //1961-09-22 17:53:19 -05:00
|
||||
f->ts5 = (Timespec){2873938879LL, 0}; //2061-01-25 23:21:19 -05:00
|
||||
f->t1 = 607009407; //1989-3-27 13:43:27 Z
|
||||
f->t2 = 1604748079; //2020-11-7 06:21:19 -05:00
|
||||
f->t3 = 1341398864; //2012-07-04 19:27:44 +08:40
|
||||
f->t4 = -261104801; //1961-09-22 17:53:19 -05:00
|
||||
f->t5 = 2873938879LL; //2061-01-25 23:21:19 -05:00
|
||||
}
|
||||
|
||||
typedef struct
|
||||
@ -492,217 +492,23 @@ test_gnc_setlocale (int category, gchar *locale)
|
||||
"if a suffix is needed it's in the suffixes array.");
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
/* timespec_normalize
|
||||
static void
|
||||
timespec_normalize(Timespec *t)// Local: 2:0:0
|
||||
*/
|
||||
static void
|
||||
test_timespec_normalize (void)
|
||||
{
|
||||
const int offset = 4396432;
|
||||
const int factor = 2;
|
||||
int base = 50;
|
||||
Timespec t = { base, factor * NANOS_PER_SECOND + offset };
|
||||
Testfuncs *tf = gnc_date_load_funcs ();
|
||||
|
||||
tf->timespec_normalize (&t);
|
||||
g_assert_cmpint (t.tv_sec, ==, base + factor);
|
||||
g_assert_cmpint (t.tv_nsec, ==, offset);
|
||||
|
||||
t.tv_sec = base;
|
||||
t.tv_nsec = - factor * NANOS_PER_SECOND - offset;
|
||||
tf->timespec_normalize (&t);
|
||||
g_assert_cmpint (t.tv_sec, ==, base - factor - 1);
|
||||
g_assert_cmpint (t.tv_nsec, ==, NANOS_PER_SECOND - offset);
|
||||
|
||||
t.tv_sec = - base;
|
||||
t.tv_nsec = factor * NANOS_PER_SECOND + offset;
|
||||
tf->timespec_normalize (&t);
|
||||
g_assert_cmpint (t.tv_sec, ==, - base + factor + 1);
|
||||
g_assert_cmpint (t.tv_nsec, ==, - NANOS_PER_SECOND + offset);
|
||||
|
||||
t.tv_sec = - base;
|
||||
t.tv_nsec = - factor * NANOS_PER_SECOND - offset;
|
||||
tf->timespec_normalize (&t);
|
||||
g_assert_cmpint (t.tv_sec, ==, - base - factor);
|
||||
g_assert_cmpint (t.tv_nsec, ==, - offset);
|
||||
|
||||
g_slice_free (Testfuncs, tf);
|
||||
}
|
||||
|
||||
|
||||
/* timespec_equal
|
||||
gboolean
|
||||
timespec_equal (const Timespec *ta, const Timespec *tb)// C: 19 in 8 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_timespec_equal (void)
|
||||
{
|
||||
const int sec_per_day = 24 * 3600;
|
||||
const int sec_per_mo = 30 * sec_per_day;
|
||||
const time64 sec_per_yr = 365 * sec_per_day;
|
||||
const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892;
|
||||
const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day;
|
||||
const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day;
|
||||
const time64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day;
|
||||
Timespec ta = { secs1, nsec1 };
|
||||
Timespec tb = { secs2, nsec2 };
|
||||
Timespec tc = { secs1, nsec1 };
|
||||
Timespec td = { secs3, nsec1 };
|
||||
Timespec te = { secs1, nsec2 };
|
||||
Timespec tf = { secs2 - 1, nsec3 }; /* When normalized, equal to tb */
|
||||
|
||||
g_assert (timespec_equal (&ta, &ta));
|
||||
g_assert (timespec_equal (&ta, &tc));
|
||||
g_assert (!timespec_equal (&ta, &tb));
|
||||
g_assert (!timespec_equal (&ta, &td));
|
||||
g_assert (!timespec_equal (&ta, &te));
|
||||
g_assert (timespec_equal (&tb, &tf));
|
||||
}
|
||||
/* timespec_cmp
|
||||
gint
|
||||
timespec_cmp(const Timespec *ta, const Timespec *tb)// C: 28 in 11 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_timespec_cmp (void)
|
||||
{
|
||||
const int sec_per_day = 24 * 3600;
|
||||
const int sec_per_mo = 30 * sec_per_day;
|
||||
const time64 sec_per_yr = 365 * sec_per_day;
|
||||
const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892;
|
||||
const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day;
|
||||
const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day;
|
||||
const time64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day;
|
||||
Timespec ta = { secs1, nsec1 };
|
||||
Timespec tb = { secs2, nsec2 };
|
||||
Timespec tc = { secs1, nsec1 };
|
||||
Timespec td = { secs3, nsec1 };
|
||||
Timespec te = { secs1, nsec2 };
|
||||
Timespec tf = { secs2 - 1, nsec3 }; /* When normalized, equal to tb */
|
||||
Timespec tg = { -secs2, nsec2 };
|
||||
Timespec th = { secs1, -nsec1 };
|
||||
|
||||
g_assert_cmpint (timespec_cmp (&ta, &ta), ==, 0);
|
||||
g_assert_cmpint (timespec_cmp (&ta, &tc), ==, 0);
|
||||
g_assert_cmpint (timespec_cmp (&tf, &tb), ==, 0);
|
||||
g_assert_cmpint (timespec_cmp (&ta, &tb), ==, 1);
|
||||
g_assert_cmpint (timespec_cmp (&te, &ta), ==, 1);
|
||||
g_assert_cmpint (timespec_cmp (&td, &ta), ==, 1);
|
||||
g_assert_cmpint (timespec_cmp (&ta, &te), ==, -1);
|
||||
g_assert_cmpint (timespec_cmp (&ta, &tg), ==, 1);
|
||||
g_assert_cmpint (timespec_cmp (&th, &ta), ==, -1);
|
||||
|
||||
}
|
||||
/* timespec_diff
|
||||
Timespec
|
||||
timespec_diff(const Timespec *ta, const Timespec *tb)// C: 4 in 1 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_timespec_diff (void)
|
||||
{
|
||||
const gint sec_per_day = 24 * 3600;
|
||||
const gint sec_per_mo = 30 * sec_per_day;
|
||||
const time64 sec_per_yr = 365 * sec_per_day;
|
||||
const time64 nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892;
|
||||
const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day;
|
||||
const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day;
|
||||
const time64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day;
|
||||
Timespec ta = { secs1, nsec1 };
|
||||
Timespec tb = { secs2, nsec2 };
|
||||
Timespec td = { secs3, nsec1 };
|
||||
Timespec te = { secs1, nsec2 };
|
||||
Timespec tf = { secs2 - 1, nsec3 }; /* When normalized, equal to tb */
|
||||
Timespec tg = { -secs2, nsec2 };
|
||||
Timespec th = { secs1, -nsec3 };
|
||||
|
||||
Timespec tt = timespec_diff (&ta, &ta);
|
||||
|
||||
g_assert_cmpint (tt.tv_sec, ==, 0);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, 0);
|
||||
|
||||
tt = timespec_diff (&ta, &tb);
|
||||
g_assert_cmpint (tt.tv_sec, ==, secs1 - secs2 - 1);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, nsec1 - nsec2 + NANOS_PER_SECOND);
|
||||
|
||||
tt = timespec_diff (&ta, &te);
|
||||
g_assert_cmpint (tt.tv_sec, ==, 0);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, nsec1 - nsec2);
|
||||
|
||||
tt = timespec_diff (&tb, &tf);
|
||||
g_assert_cmpint (tt.tv_sec, ==, 0);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, 0);
|
||||
|
||||
tt = timespec_diff (&tf, &th);
|
||||
if (sizeof (glong) > 4)
|
||||
{
|
||||
glong nsec_diff_norm = 2 * nsec3 - 2 * NANOS_PER_SECOND - NANOS_PER_SECOND;
|
||||
g_assert_cmpint (tt.tv_sec, ==, secs2 - secs1 + 2);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, nsec_diff_norm);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_cmpint (tt.tv_sec, ==, secs2 - secs1 - 3);
|
||||
g_assert_cmpint (tt.tv_nsec, <, 0); /* Overflow nanosecs */
|
||||
}
|
||||
tt = timespec_diff (&tg, &td);
|
||||
g_assert_cmpint (tt.tv_sec, ==, -secs2 - secs3 + 1);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, nsec2 - nsec1 - NANOS_PER_SECOND);
|
||||
|
||||
}
|
||||
/* timespec_abs
|
||||
Timespec
|
||||
timespec_abs(const Timespec *t)// C: 4 in 1 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_timespec_abs (void)
|
||||
{
|
||||
const int sec_per_day = 24 * 3600;
|
||||
const int sec_per_mo = 30 * sec_per_day;
|
||||
const int sec_per_yr = 365 * sec_per_day;
|
||||
const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892;
|
||||
const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day;
|
||||
const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day;
|
||||
Timespec ta = { secs1, nsec1 };
|
||||
Timespec tf = { secs2 - 1, nsec3 }; /* When normalized, equal to tb */
|
||||
Timespec tg = { -secs2, nsec2 };
|
||||
Timespec th = { secs1, -nsec1 };
|
||||
|
||||
Timespec tt = timespec_abs (&ta);
|
||||
g_assert_cmpint (tt.tv_sec, ==, secs1);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, nsec1);
|
||||
|
||||
tt = timespec_abs (&tf);
|
||||
g_assert_cmpint (tt.tv_sec, ==, secs2);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, nsec2);
|
||||
|
||||
tt = timespec_abs (&tg);
|
||||
g_assert_cmpint (tt.tv_sec, ==, secs2 - 1);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, NANOS_PER_SECOND - nsec2);
|
||||
|
||||
tt = timespec_abs (&th);
|
||||
g_assert_cmpint (tt.tv_sec, ==, secs1 - 1);
|
||||
g_assert_cmpint (tt.tv_nsec, ==, NANOS_PER_SECOND - nsec1);
|
||||
|
||||
}
|
||||
/* timespecCanonicalDayTime
|
||||
Timespec
|
||||
timespecCanonicalDayTime(Timespec t)// C: 12 in 5 SCM: 19 in 10 Local: 0:0:0
|
||||
time64
|
||||
time64CanonicalDayTime(time64 t)// C: 12 in 5 SCM: 19 in 10 Local: 0:0:0
|
||||
*/
|
||||
static Timespec
|
||||
compute_noon_of_day (Timespec *ts)
|
||||
static time64
|
||||
compute_noon_of_day (const time64 *t)
|
||||
{
|
||||
Timespec nt = {0, 0};
|
||||
time_t secs = (time_t)ts->tv_sec;
|
||||
struct tm *time = localtime(&secs);
|
||||
time->tm_hour = 12;
|
||||
time->tm_min = 0;
|
||||
time->tm_sec = 0;
|
||||
nt.tv_sec = mktime(time);
|
||||
return nt;
|
||||
struct tm time;
|
||||
gnc_localtime_r(t, &time);
|
||||
time.tm_hour = 12;
|
||||
time.tm_min = 0;
|
||||
time.tm_sec = 0;
|
||||
return gnc_mktime(&time);
|
||||
}
|
||||
|
||||
static void
|
||||
test_timespecCanonicalDayTime (void)
|
||||
test_time64CanonicalDayTime (void)
|
||||
{
|
||||
const int sec_per_day = 24 * 3600;
|
||||
const int sec_per_mo = 30 * sec_per_day;
|
||||
@ -713,21 +519,17 @@ test_timespecCanonicalDayTime (void)
|
||||
const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo +
|
||||
19 * sec_per_day + 21 * 3600 + 9 * 60 + 48; /* 1991-11-19 21:09:48 Z */
|
||||
|
||||
Timespec t0 = { secs, 0 };
|
||||
Timespec ta = { secs1, 0 };
|
||||
Timespec tb = { secs2, 0 };
|
||||
time64 n0 = compute_noon_of_day (&secs);
|
||||
time64 na = compute_noon_of_day (&secs1);
|
||||
time64 nb = compute_noon_of_day (&secs2);
|
||||
|
||||
Timespec n0 = compute_noon_of_day (&t0);
|
||||
Timespec na = compute_noon_of_day (&ta);
|
||||
Timespec nb = compute_noon_of_day (&tb);
|
||||
time64 r0 = time64CanonicalDayTime (secs);
|
||||
time64 ra = time64CanonicalDayTime (secs1);
|
||||
time64 rb = time64CanonicalDayTime (secs2);
|
||||
|
||||
Timespec r0 = timespecCanonicalDayTime (t0);
|
||||
Timespec ra = timespecCanonicalDayTime (ta);
|
||||
Timespec rb = timespecCanonicalDayTime (tb);
|
||||
|
||||
g_assert_cmpint (n0.tv_sec, ==, r0.tv_sec);
|
||||
g_assert_cmpint (na.tv_sec, ==, ra.tv_sec);
|
||||
g_assert_cmpint (nb.tv_sec, ==, rb.tv_sec);
|
||||
g_assert_cmpint (n0, ==, r0);
|
||||
g_assert_cmpint (na, ==, ra);
|
||||
g_assert_cmpint (nb, ==, rb);
|
||||
|
||||
}
|
||||
|
||||
@ -1339,74 +1141,6 @@ test_qof_print_date (void)
|
||||
setlocale (LC_TIME, locale);
|
||||
g_free (locale);
|
||||
}
|
||||
/* gnc_print_date
|
||||
const char *
|
||||
gnc_print_date (Timespec ts)// C: 11 in 9 SCM: 166 in 59 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_gnc_print_date (void)
|
||||
{
|
||||
gchar t_buff[MAX_DATE_LENGTH];
|
||||
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
|
||||
GDate *gd1 = g_date_new_dmy (23, 11, 1974);
|
||||
GDate *gd2 = g_date_new_dmy (2, 2, 1961);
|
||||
GDate *gd3 = g_date_new_dmy (16, 6, 2045);
|
||||
Timespec tm1 = gdate_to_timespec (*gd1);
|
||||
Timespec tm2 = gdate_to_timespec (*gd2);
|
||||
Timespec tm3 = gdate_to_timespec (*gd3);
|
||||
|
||||
|
||||
qof_date_format_set (QOF_DATE_FORMAT_UK);
|
||||
g_assert_cmpstr (gnc_print_date (tm1), ==, "23/11/1974");
|
||||
g_assert_cmpstr (gnc_print_date (tm2), ==, "02/02/1961");
|
||||
g_assert_cmpstr (gnc_print_date (tm3), ==, "16/06/2045");
|
||||
|
||||
qof_date_format_set (QOF_DATE_FORMAT_CE);
|
||||
g_assert_cmpstr (gnc_print_date (tm1), ==, "23.11.1974");
|
||||
g_assert_cmpstr (gnc_print_date (tm2), ==, "02.02.1961");
|
||||
g_assert_cmpstr (gnc_print_date (tm3), ==, "16.06.2045");
|
||||
|
||||
qof_date_format_set (QOF_DATE_FORMAT_US);
|
||||
g_assert_cmpstr (gnc_print_date (tm1), ==, "11/23/1974");
|
||||
g_assert_cmpstr (gnc_print_date (tm2), ==, "02/02/1961");
|
||||
g_assert_cmpstr (gnc_print_date (tm3), ==, "06/16/2045");
|
||||
|
||||
qof_date_format_set (QOF_DATE_FORMAT_ISO);
|
||||
g_assert_cmpstr (gnc_print_date (tm1), ==, "1974-11-23");
|
||||
g_assert_cmpstr (gnc_print_date (tm2), ==, "1961-02-02");
|
||||
g_assert_cmpstr (gnc_print_date (tm3), ==, "2045-06-16");
|
||||
|
||||
qof_date_format_set (QOF_DATE_FORMAT_LOCALE);
|
||||
test_gnc_setlocale (LC_TIME, "en_US");
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd1);
|
||||
g_assert_cmpstr (gnc_print_date (tm1), ==, t_buff);
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd2);
|
||||
g_assert_cmpstr (gnc_print_date (tm2), ==, t_buff);
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd3);
|
||||
g_assert_cmpstr (gnc_print_date (tm3), ==, t_buff);
|
||||
|
||||
test_gnc_setlocale (LC_TIME, "en_GB");
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd1);
|
||||
g_assert_cmpstr (gnc_print_date (tm1), ==, t_buff);
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd2);
|
||||
g_assert_cmpstr (gnc_print_date (tm2), ==, t_buff);
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd3);
|
||||
g_assert_cmpstr (gnc_print_date (tm3), ==, t_buff);
|
||||
|
||||
test_gnc_setlocale (LC_TIME, "fr_FR");
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd1);
|
||||
g_assert_cmpstr (gnc_print_date (tm1), ==, t_buff);
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd2);
|
||||
g_assert_cmpstr (gnc_print_date (tm2), ==, t_buff);
|
||||
g_date_strftime (t_buff, MAX_DATE_LENGTH, GNC_D_FMT, gd3);
|
||||
g_assert_cmpstr (gnc_print_date (tm3), ==, t_buff);
|
||||
|
||||
setlocale (LC_TIME, locale);
|
||||
g_free (locale);
|
||||
g_date_free (gd1);
|
||||
g_date_free (gd2);
|
||||
g_date_free (gd3);
|
||||
}
|
||||
/* floordiv
|
||||
static int
|
||||
floordiv(int a, int b)// Local: 1:0:0
|
||||
@ -1622,9 +1356,9 @@ test_gnc_date_timestamp (void)
|
||||
|
||||
g_free (timestr);
|
||||
}
|
||||
/* gnc_iso8601_to_timespec_gmt
|
||||
Timespec
|
||||
gnc_iso8601_to_timespec_gmt(const char *str)// C: 6 in 3 Local: 0:0:0
|
||||
/* gnc_iso8601_to_time64_gmt
|
||||
time64
|
||||
gnc_iso8601_to_time64_gmt(const char *str)// C: 6 in 3 Local: 0:0:0
|
||||
*/
|
||||
static gint
|
||||
get_nanoseconds (GDateTime *gdt)
|
||||
@ -1642,44 +1376,43 @@ test_gnc_iso8601_to_time64_gmt (FixtureA *f, gconstpointer pData)
|
||||
g_assert_cmpint (t, ==, 0);
|
||||
|
||||
t = gnc_iso8601_to_time64_gmt ("1989-03-27 13:43:27");
|
||||
g_assert_cmpint (t, ==, f->ts1.tv_sec);
|
||||
g_assert_cmpint (t, ==, f->t1);
|
||||
|
||||
t = gnc_iso8601_to_time64_gmt ("2020-11-07 06:21:19 -05");
|
||||
g_assert_cmpint (t, ==, f->ts2.tv_sec);
|
||||
g_assert_cmpint (t, ==, f->t2);
|
||||
|
||||
t = gnc_iso8601_to_time64_gmt ("2012-07-04 19:27:44.0+08:40");
|
||||
g_assert_cmpint (t, ==, f->ts3.tv_sec);
|
||||
g_assert_cmpint (t, ==, f->t3);
|
||||
|
||||
t = gnc_iso8601_to_time64_gmt ("1961-09-22 17:53:19 -05");
|
||||
g_assert_cmpint (t, ==, f->ts4.tv_sec);
|
||||
g_assert_cmpint (t, ==, f->t4);
|
||||
|
||||
t = gnc_iso8601_to_time64_gmt ("2061-01-25 23:21:19.0 -05:00");
|
||||
g_assert_cmpint (t, ==, f->ts5.tv_sec);
|
||||
g_assert_cmpint (t, ==, f->t5);
|
||||
}
|
||||
/* gnc_timespec_to_iso8601_buff
|
||||
/* gnc_time64_to_iso8601_buff
|
||||
char *
|
||||
gnc_timespec_to_iso8601_buff (Timespec ts, char * buff)// C: 18 in 7 Local: 0:0:0
|
||||
gnc_time64_to_iso8601_buff (time64 t, char * buff)// C: 18 in 7 Local: 0:0:0
|
||||
*/
|
||||
static Timespec
|
||||
g_date_time_to_timespec (GDateTime *gdt)
|
||||
static time64
|
||||
g_date_time_to_time64 (GDateTime *gdt)
|
||||
{
|
||||
Timespec t;
|
||||
t.tv_sec = g_date_time_to_unix (gdt);
|
||||
t.tv_nsec = g_date_time_get_microsecond (gdt) * 1000;
|
||||
time64 t;
|
||||
t = g_date_time_to_unix (gdt);
|
||||
return t;
|
||||
}
|
||||
|
||||
#define ISO8601_SIZE MAX_DATE_LENGTH + 4
|
||||
static gchar*
|
||||
format_timestring (Timespec ts, TZOffset tz)
|
||||
format_timestring (time64 t, TZOffset tz)
|
||||
{
|
||||
static const unsigned tzlen = MAX_DATE_LENGTH - 26;
|
||||
char *fmt = "%Y-%m-%d %H:%M:%S";
|
||||
static const unsigned tzlen = MAX_DATE_LENGTH - 26;
|
||||
char *fmt = "%Y-%m-%d %H:%M:%S %z";
|
||||
struct tm tm;
|
||||
char buf[MAX_DATE_LENGTH], *retval;
|
||||
char buf[MAX_DATE_LENGTH + 1];
|
||||
char tzbuf[tzlen];
|
||||
memset(tzbuf, 0, sizeof(tzbuf));
|
||||
gnc_localtime_r(&ts.tv_sec, &tm);
|
||||
gnc_localtime_r(&t, &tm);
|
||||
#if PLATFORM(WINDOWS)
|
||||
strftime(tzbuf, sizeof(tzbuf), "%Z", &tm);
|
||||
#else
|
||||
@ -1687,121 +1420,73 @@ format_timestring (Timespec ts, TZOffset tz)
|
||||
#endif
|
||||
memset (buf, 0, sizeof(buf));
|
||||
strftime(buf, sizeof(buf), fmt, &tm);
|
||||
retval = g_strdup_printf ("%s.%06ld %s", buf, ts.tv_nsec / 1000, tzbuf);
|
||||
|
||||
return retval;
|
||||
return g_strdup(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
test_gnc_timespec_to_iso8601_buff (FixtureA *f, gconstpointer pData)
|
||||
test_gnc_time64_to_iso8601_buff (FixtureA *f, gconstpointer pData)
|
||||
{
|
||||
|
||||
gchar buff[ISO8601_SIZE];
|
||||
gchar *time_str;
|
||||
Timespec t = { 0, 0 };
|
||||
time64 t = 0;
|
||||
gchar *end;
|
||||
|
||||
memset (buff, 0, sizeof buff);
|
||||
|
||||
end = gnc_timespec_to_iso8601_buff (t, NULL);
|
||||
end = gnc_time64_to_iso8601_buff (t, NULL);
|
||||
g_assert (end == NULL);
|
||||
|
||||
end = gnc_timespec_to_iso8601_buff (f->ts0, buff);
|
||||
end = gnc_time64_to_iso8601_buff (f->t0, buff);
|
||||
g_assert_cmpint (end - buff, ==, strlen (buff));
|
||||
time_str = format_timestring (f->ts0, f->off_zulu);
|
||||
time_str = format_timestring (f->t0, f->off_zulu);
|
||||
g_assert_cmpstr (buff, ==, time_str);
|
||||
g_free (time_str);
|
||||
|
||||
end = gnc_timespec_to_iso8601_buff (f->ts1, buff);
|
||||
time_str = format_timestring (f->ts1, f->off_zulu);
|
||||
end = gnc_time64_to_iso8601_buff (f->t1, buff);
|
||||
time_str = format_timestring (f->t1, f->off_zulu);
|
||||
g_assert_cmpstr (buff, ==, time_str);
|
||||
g_free (time_str);
|
||||
|
||||
|
||||
end = gnc_timespec_to_iso8601_buff (f->ts2, buff);
|
||||
time_str = format_timestring (f->ts2, f->off_05w);
|
||||
end = gnc_time64_to_iso8601_buff (f->t2, buff);
|
||||
time_str = format_timestring (f->t2, f->off_05w);
|
||||
g_assert_cmpstr (buff, ==, time_str);
|
||||
g_free (time_str);
|
||||
|
||||
end = gnc_timespec_to_iso8601_buff (f->ts3, buff);
|
||||
time_str = format_timestring (f->ts3, f->off_0840e);
|
||||
end = gnc_time64_to_iso8601_buff (f->t3, buff);
|
||||
time_str = format_timestring (f->t3, f->off_0840e);
|
||||
g_assert_cmpstr (buff, ==, time_str);
|
||||
g_free (time_str);
|
||||
|
||||
end = gnc_timespec_to_iso8601_buff (f->ts4, buff);
|
||||
time_str = format_timestring (f->ts4, f->off_05w);
|
||||
end = gnc_time64_to_iso8601_buff (f->t4, buff);
|
||||
time_str = format_timestring (f->t4, f->off_05w);
|
||||
g_assert_cmpstr (buff, ==, time_str);
|
||||
g_free (time_str);
|
||||
|
||||
end = gnc_timespec_to_iso8601_buff (f->ts5, buff);
|
||||
time_str = format_timestring (f->ts5, f->off_05w);
|
||||
end = gnc_time64_to_iso8601_buff (f->t5, buff);
|
||||
time_str = format_timestring (f->t5, f->off_05w);
|
||||
g_assert_cmpstr (buff, ==, time_str);
|
||||
g_free (time_str);
|
||||
}
|
||||
/* gnc_timespec2dmy
|
||||
void
|
||||
gnc_timespec2dmy (Timespec t, int *day, int *month, int *year)// C: 1 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_gnc_timespec2dmy (FixtureA *f, gconstpointer pData)
|
||||
{
|
||||
struct tm tm;
|
||||
int day, r_day, mo, r_mo, yr, r_yr;
|
||||
|
||||
|
||||
gnc_timespec2dmy (f->ts0, &r_day, &r_mo, &r_yr);
|
||||
gnc_localtime_r (&f->ts0.tv_sec, &tm);
|
||||
g_assert_cmpint (r_day, ==, tm.tm_mday);
|
||||
g_assert_cmpint (r_mo, ==, tm.tm_mon + 1);
|
||||
g_assert_cmpint (r_yr, ==, tm.tm_year + 1900);
|
||||
|
||||
gnc_timespec2dmy (f->ts1, &r_day, &r_mo, &r_yr);
|
||||
gnc_localtime_r (&f->ts1.tv_sec, &tm);
|
||||
g_assert_cmpint (r_day, ==, tm.tm_mday);
|
||||
g_assert_cmpint (r_mo, ==, tm.tm_mon + 1);
|
||||
g_assert_cmpint (r_yr, ==, tm.tm_year + 1900);
|
||||
|
||||
gnc_timespec2dmy (f->ts2, &r_day, &r_mo, &r_yr);
|
||||
gnc_localtime_r (&f->ts2.tv_sec, &tm);
|
||||
g_assert_cmpint (r_day, ==, tm.tm_mday);
|
||||
g_assert_cmpint (r_mo, ==, tm.tm_mon + 1);
|
||||
g_assert_cmpint (r_yr, ==, tm.tm_year + 1900);
|
||||
|
||||
gnc_timespec2dmy (f->ts3, &r_day, &r_mo, &r_yr);
|
||||
gnc_localtime_r (&f->ts3.tv_sec, &tm);
|
||||
g_assert_cmpint (r_day, ==, tm.tm_mday);
|
||||
g_assert_cmpint (r_mo, ==, tm.tm_mon + 1);
|
||||
g_assert_cmpint (r_yr, ==, tm.tm_year + 1900);
|
||||
|
||||
gnc_timespec2dmy (f->ts4, &r_day, &r_mo, &r_yr);
|
||||
gnc_localtime_r (&f->ts4.tv_sec, &tm);
|
||||
g_assert_cmpint (r_day, ==, tm.tm_mday);
|
||||
g_assert_cmpint (r_mo, ==, tm.tm_mon + 1);
|
||||
g_assert_cmpint (r_yr, ==, tm.tm_year + 1900);
|
||||
|
||||
gnc_timespec2dmy (f->ts5, &r_day, &r_mo, &r_yr);
|
||||
gnc_localtime_r (&f->ts5.tv_sec, &tm);
|
||||
g_assert_cmpint (r_day, ==, tm.tm_mday);
|
||||
g_assert_cmpint (r_mo, ==, tm.tm_mon + 1);
|
||||
g_assert_cmpint (r_yr, ==, tm.tm_year + 1900);
|
||||
|
||||
}
|
||||
/* gnc_dmy2timespec_internal
|
||||
static Timespec
|
||||
gnc_dmy2timespec_internal (int day, int month, int year, gboolean start_of_day)// Local: 2:0:0
|
||||
/* gnc_dmy2time64_internal
|
||||
static time64
|
||||
gnc_dmy2time64_internal (int day, int month, int year, gboolean start_of_day)// Local: 2:0:0
|
||||
*/
|
||||
/* static void
|
||||
test_gnc_dmy2timespec_internal (void)
|
||||
test_gnc_dmy2time64_internal (void)
|
||||
{
|
||||
}*/
|
||||
/* gnc_dmy2timespec
|
||||
Timespec
|
||||
gnc_dmy2timespec (int day, int month, int year)// C: 8 in 5 Local: 1:0:0
|
||||
/* gnc_dmy2time64
|
||||
time64
|
||||
gnc_dmy2time64 (int day, int month, int year)// C: 8 in 5 Local: 1:0:0
|
||||
*/
|
||||
static void
|
||||
test_gnc_dmy2timespec (FixtureB *f, gconstpointer pData)
|
||||
test_gnc_dmy2time64 (FixtureB *f, gconstpointer pData)
|
||||
{
|
||||
gchar *msg1 = "[qof_dmy2timespec()] Date computation error from Y-M-D 1257-7-2: Time value is outside the supported year range.";
|
||||
gchar *msg1 = "[qof_dmy2time64()] Date computation error from Y-M-D 1257-7-2: Time value is outside the supported year range.";
|
||||
gint loglevel = G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL;
|
||||
gchar *logdomain = "qof.engine";
|
||||
TestErrorStruct check = {loglevel, logdomain, msg1, 0};
|
||||
@ -1816,27 +1501,27 @@ test_gnc_dmy2timespec (FixtureB *f, gconstpointer pData)
|
||||
struct tm tm = {0, 0, 0, f->test[i].day, f->test[i].mon - 1,
|
||||
f->test[i].yr - 1900, 0, 0, -1};
|
||||
#endif
|
||||
Timespec r_t = gnc_dmy2timespec (f->test[i].day, f->test[i].mon,
|
||||
time64 r_t = gnc_dmy2time64 (f->test[i].day, f->test[i].mon,
|
||||
f->test[i].yr);
|
||||
struct tm time1 = tm, time2 = tm;
|
||||
int offset = gnc_mktime(&time1) - gnc_timegm(&time2);
|
||||
if (f->test[i].secs == INT64_MAX)
|
||||
/* We use INT64_MAX as invalid timespec.secs.
|
||||
/* We use INT64_MAX as invalid time64.secs.
|
||||
* As we can't *add* to the max, we can ignore the tz offset in this case. */
|
||||
g_assert_cmpint (r_t.tv_sec, ==, INT64_MAX);
|
||||
g_assert_cmpint (r_t, ==, INT64_MAX);
|
||||
else
|
||||
g_assert_cmpint (r_t.tv_sec, ==, f->test[i].secs - offset);
|
||||
g_assert_cmpint (r_t, ==, f->test[i].secs - offset);
|
||||
}
|
||||
g_log_set_default_handler (hdlr, 0);
|
||||
}
|
||||
/* gnc_dmy2timespec_end
|
||||
Timespec
|
||||
gnc_dmy2timespec_end (int day, int month, int year)// C: 1 Local: 0:0:0
|
||||
/* gnc_dmy2time64_end
|
||||
time64
|
||||
gnc_dmy2time64_end (int day, int month, int year)// C: 1 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_gnc_dmy2timespec_end (FixtureB *f, gconstpointer pData)
|
||||
test_gnc_dmy2time64_end (FixtureB *f, gconstpointer pData)
|
||||
{
|
||||
gchar *msg1 = "[qof_dmy2timespec_end()] Date computation error from Y-M-D 1257-7-2: Time value is outside the supported year range.";
|
||||
gchar *msg1 = "[qof_dmy2time64_end()] Date computation error from Y-M-D 1257-7-2: Time value is outside the supported year range.";
|
||||
gint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
gchar *logdomain = "qof.engine";
|
||||
TestErrorStruct check = {loglevel, logdomain, msg1, 0};
|
||||
@ -1851,15 +1536,15 @@ test_gnc_dmy2timespec_end (FixtureB *f, gconstpointer pData)
|
||||
struct tm tm = {59, 59, 23, f->test[i].day, f->test[i].mon - 1,
|
||||
f->test[i].yr - 1900, 0, 0, -1};
|
||||
#endif
|
||||
Timespec r_t = gnc_dmy2timespec_end (f->test[i].day, f->test[i].mon,
|
||||
time64 r_t = gnc_dmy2time64_end (f->test[i].day, f->test[i].mon,
|
||||
f->test[i].yr);
|
||||
int offset = gnc_mktime(&tm) - gnc_timegm(&tm);
|
||||
if (f->test[i].secs == INT64_MAX)
|
||||
/* We use INT64_MAX as invalid timespec.secs.
|
||||
/* We use INT64_MAX as invalid time64.secs.
|
||||
* As we can't *add* to the max, we can ignore the tz offset in this case. */
|
||||
g_assert_cmpint (r_t.tv_sec, ==, INT64_MAX);
|
||||
g_assert_cmpint (r_t, ==, INT64_MAX);
|
||||
else
|
||||
g_assert_cmpint (r_t.tv_sec, ==, f->test[i].secs - offset);
|
||||
g_assert_cmpint (r_t, ==, f->test[i].secs - offset);
|
||||
}
|
||||
g_log_set_default_handler (hdlr, 0);
|
||||
}
|
||||
@ -1880,18 +1565,18 @@ offset_adjust(GDateTime *gdt)
|
||||
return new_gdt;
|
||||
}
|
||||
|
||||
/*gnc_dmy2timespec_neutral*/
|
||||
/*gnc_dmy2time64_neutral*/
|
||||
static void
|
||||
test_gnc_dmy2timespec_neutral (FixtureB *f, gconstpointer pData)
|
||||
test_gnc_dmy2time64_neutral (FixtureB *f, gconstpointer pData)
|
||||
{
|
||||
gchar *msg1 = "[qof_dmy2timespec_neutral()] Date computation error from Y-M-D 1257-7-2: Time value is outside the supported year range.";
|
||||
gchar *msg1 = "[qof_dmy2time64_neutral()] Date computation error from Y-M-D 1257-7-2: Time value is outside the supported year range.";
|
||||
gint loglevel = G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL;
|
||||
gchar *logdomain = "qof.engine";
|
||||
TestErrorStruct check = {loglevel, logdomain, msg1, 0};
|
||||
GLogFunc hdlr = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
|
||||
struct tm check_tz;
|
||||
gnc_localtime_r(&(f->test[0].secs), &check_tz);
|
||||
/* gnc_dmy2timespec_neutral returns the timespec for 10:59:00 Z
|
||||
/* gnc_dmy2time64_neutral returns the time64 for 10:59:00 Z
|
||||
* for timezones in the range -11 to +13. If the timezone being
|
||||
* tested is outside that range then the day of the month will be
|
||||
* different from the one in the test fixture and we skip the
|
||||
@ -1902,10 +1587,10 @@ test_gnc_dmy2timespec_neutral (FixtureB *f, gconstpointer pData)
|
||||
g_test_log_set_fatal_handler ((GTestLogFatalFunc)test_checked_handler, &check);
|
||||
for (int i = 0; i < sizeof(f->test)/sizeof(TimeMap); ++i)
|
||||
{
|
||||
Timespec r_t = gnc_dmy2timespec_neutral (f->test[i].day, f->test[i].mon,
|
||||
time64 r_t = gnc_dmy2time64_neutral (f->test[i].day, f->test[i].mon,
|
||||
f->test[i].yr);
|
||||
|
||||
g_assert_cmpint (r_t.tv_sec, ==, f->test[i].secs);
|
||||
g_assert_cmpint (r_t, ==, f->test[i].secs);
|
||||
}
|
||||
}
|
||||
g_log_set_default_handler (hdlr, 0);
|
||||
@ -1919,83 +1604,59 @@ gnc_timezone (const struct tm *tm)// C: 5 in 2 Local: 2:0:0
|
||||
test_gnc_timezone (void)
|
||||
{
|
||||
}*/
|
||||
/* timespecFromtime64
|
||||
void
|
||||
timespecFromtime64( Timespec *ts, time64 t )// C: 22 in 11 Local: 0:0:0
|
||||
*/
|
||||
/* static void
|
||||
test_timespecFromtime64 (void)
|
||||
{
|
||||
}*/
|
||||
/* timespec_now
|
||||
Timespec
|
||||
timespec_now()// C: 2 in 2 Local: 0:0:0
|
||||
*/
|
||||
/* static void
|
||||
test_timespec_now (void)
|
||||
{
|
||||
}*/
|
||||
/* timespecTotime64
|
||||
time64
|
||||
timespecTotime64 (Timespec ts)// C: 10 in 6 Local: 1:0:0
|
||||
*/
|
||||
/* static void
|
||||
test_timespecTotime64 (void)
|
||||
{
|
||||
}*/
|
||||
/* timespec_to_gdate
|
||||
GDate timespec_to_gdate (Timespec ts)// C: 5 in 4 Local: 0:0:0
|
||||
/* time64_to_gdate
|
||||
GDate time64_to_gdate (time64 t)// C: 5 in 4 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_timespec_to_gdate (FixtureA *f, gconstpointer pData)
|
||||
test_time64_to_gdate (FixtureA *f, gconstpointer pData)
|
||||
{
|
||||
GDate date1, date2;
|
||||
struct tm tm;
|
||||
|
||||
g_date_clear (&date2, 1);
|
||||
|
||||
date1 = timespec_to_gdate (f->ts0);
|
||||
gnc_localtime_r(&f->ts0.tv_sec, &tm);
|
||||
date1 = time64_to_gdate (f->t0);
|
||||
gnc_localtime_r(&f->t0, &tm);
|
||||
g_date_set_dmy (&date2, tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
|
||||
g_assert_cmpint (g_date_get_julian (&date1), ==,
|
||||
g_date_get_julian (&date2));
|
||||
|
||||
date1 = timespec_to_gdate (f->ts1);
|
||||
gnc_localtime_r(&f->ts1.tv_sec, &tm);
|
||||
date1 = time64_to_gdate (f->t1);
|
||||
gnc_localtime_r(&f->t1, &tm);
|
||||
g_date_set_dmy (&date2, tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
|
||||
g_assert_cmpint (g_date_get_julian (&date1), ==,
|
||||
g_date_get_julian (&date2));
|
||||
|
||||
date1 = timespec_to_gdate (f->ts2);
|
||||
gnc_localtime_r(&f->ts2.tv_sec, &tm);
|
||||
date1 = time64_to_gdate (f->t2);
|
||||
gnc_localtime_r(&f->t2, &tm);
|
||||
g_date_set_dmy (&date2, tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
|
||||
g_assert_cmpint (g_date_get_julian (&date1), ==,
|
||||
g_date_get_julian (&date2));
|
||||
|
||||
date1 = timespec_to_gdate (f->ts3);
|
||||
gnc_localtime_r(&f->ts3.tv_sec, &tm);
|
||||
date1 = time64_to_gdate (f->t3);
|
||||
gnc_localtime_r(&f->t3, &tm);
|
||||
g_date_set_dmy (&date2, tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
|
||||
g_assert_cmpint (g_date_get_julian (&date1), ==,
|
||||
g_date_get_julian (&date2));
|
||||
|
||||
date1 = timespec_to_gdate (f->ts4);
|
||||
gnc_localtime_r(&f->ts4.tv_sec, &tm);
|
||||
date1 = time64_to_gdate (f->t4);
|
||||
gnc_localtime_r(&f->t4, &tm);
|
||||
g_date_set_dmy (&date2, tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
|
||||
g_assert_cmpint (g_date_get_julian (&date1), ==,
|
||||
g_date_get_julian (&date2));
|
||||
|
||||
date1 = timespec_to_gdate (f->ts5);
|
||||
gnc_localtime_r(&f->ts5.tv_sec, &tm);
|
||||
date1 = time64_to_gdate (f->t5);
|
||||
gnc_localtime_r(&f->t5, &tm);
|
||||
g_date_set_dmy (&date2, tm.tm_mday, tm.tm_mon + 1, tm.tm_year + 1900);
|
||||
g_assert_cmpint (g_date_get_julian (&date1), ==,
|
||||
g_date_get_julian (&date2));
|
||||
}
|
||||
|
||||
/* gdate_to_timespec
|
||||
Timespec gdate_to_timespec (GDate d)// C: 7 in 6 Local: 0:0:0
|
||||
/* gdate_to_time64
|
||||
time64 gdate_to_time64 (GDate d)// C: 7 in 6 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_gdate_to_timespec (FixtureB *f, gconstpointer pData)
|
||||
test_gdate_to_time64 (FixtureB *f, gconstpointer pData)
|
||||
{
|
||||
|
||||
gchar *msg = "g_date_set_dmy: assertion 'g_date_valid_dmy (day, m, y)' failed";
|
||||
@ -2005,7 +1666,7 @@ test_gdate_to_timespec (FixtureB *f, gconstpointer pData)
|
||||
GLogFunc hdlr = g_log_set_default_handler ((GLogFunc)test_null_handler, &check);
|
||||
struct tm check_tz;
|
||||
gnc_localtime_r(&(f->test[0].secs), &check_tz);
|
||||
/* gdate_to_timespec returns the timespec for 10:59:00 Z
|
||||
/* gdate_to_time64 returns the time64 for 10:59:00 Z
|
||||
* for timezones in the range -11 to +13. If the timezone being
|
||||
* tested is outside that range then the day of the month will be
|
||||
* different from the one in the test fixture and we skip the
|
||||
@ -2017,15 +1678,15 @@ test_gdate_to_timespec (FixtureB *f, gconstpointer pData)
|
||||
for (int i = 0; i < sizeof(f->test)/sizeof(TimeMap); ++i)
|
||||
{
|
||||
GDate gd, gd2;
|
||||
Timespec r_t;
|
||||
time64 r_t;
|
||||
g_date_clear(&gd, 1);
|
||||
g_date_clear(&gd2, 1);
|
||||
g_date_set_dmy(&gd, f->test[i].day, f->test[i].mon, f->test[i].yr);
|
||||
r_t = gdate_to_timespec(gd);
|
||||
g_assert_cmpint (r_t.tv_sec, ==, f->test[i].secs);
|
||||
r_t = gdate_to_time64(gd);
|
||||
g_assert_cmpint (r_t, ==, f->test[i].secs);
|
||||
if (f->test[i].secs < INT64_MAX)
|
||||
{
|
||||
gd2 = timespec_to_gdate(r_t);
|
||||
gd2 = time64_to_gdate(r_t);
|
||||
g_assert (g_date_compare (&gd2, &gd) == 0);
|
||||
}
|
||||
}
|
||||
@ -2067,40 +1728,40 @@ test_gnc_time64_get_day_start (FixtureA *f, gconstpointer pData)
|
||||
struct tm tm;
|
||||
time64 t_time, r_time;
|
||||
|
||||
gnc_localtime_r(&f->ts0.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t0, &tm);
|
||||
tm_day_begin(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_start (f->ts0.tv_sec);
|
||||
r_time = gnc_time64_get_day_start (f->t0);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts1.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t1, &tm);
|
||||
tm_day_begin(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_start (f->ts1.tv_sec);
|
||||
r_time = gnc_time64_get_day_start (f->t1);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts2.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t2, &tm);
|
||||
tm_day_begin(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_start (f->ts2.tv_sec);
|
||||
r_time = gnc_time64_get_day_start (f->t2);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts3.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t3, &tm);
|
||||
tm_day_begin(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_start (f->ts3.tv_sec);
|
||||
r_time = gnc_time64_get_day_start (f->t3);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts4.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t4, &tm);
|
||||
tm_day_begin(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_start (f->ts4.tv_sec);
|
||||
r_time = gnc_time64_get_day_start (f->t4);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts5.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t5, &tm);
|
||||
tm_day_begin(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_start (f->ts5.tv_sec);
|
||||
r_time = gnc_time64_get_day_start (f->t5);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
}
|
||||
@ -2122,40 +1783,40 @@ test_gnc_time64_get_day_end (FixtureA *f, gconstpointer pData)
|
||||
struct tm tm;
|
||||
time64 t_time, r_time;
|
||||
|
||||
gnc_localtime_r(&f->ts0.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t0, &tm);
|
||||
tm_day_end(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_end (f->ts0.tv_sec);
|
||||
r_time = gnc_time64_get_day_end (f->t0);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts1.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t1, &tm);
|
||||
tm_day_end(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_end (f->ts1.tv_sec);
|
||||
r_time = gnc_time64_get_day_end (f->t1);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts2.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t2, &tm);
|
||||
tm_day_end(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_end (f->ts2.tv_sec);
|
||||
r_time = gnc_time64_get_day_end (f->t2);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts3.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t3, &tm);
|
||||
tm_day_end(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_end (f->ts3.tv_sec);
|
||||
r_time = gnc_time64_get_day_end (f->t3);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts4.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t4, &tm);
|
||||
tm_day_end(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_end (f->ts4.tv_sec);
|
||||
r_time = gnc_time64_get_day_end (f->t4);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
gnc_localtime_r(&f->ts5.tv_sec, &tm);
|
||||
gnc_localtime_r(&f->t5, &tm);
|
||||
tm_day_end(&tm);
|
||||
t_time = gnc_mktime(&tm);
|
||||
r_time = gnc_time64_get_day_end (f->ts5.tv_sec);
|
||||
r_time = gnc_time64_get_day_end (f->t5);
|
||||
g_assert_cmpint (t_time, ==, r_time);
|
||||
|
||||
}
|
||||
@ -2196,26 +1857,26 @@ gnc_dow_abbrev(gchar *buf, int buf_len, int dow)// C: 4 in 2 Local: 0:0:0
|
||||
test_gnc_dow_abbrev (void)
|
||||
{
|
||||
}*/
|
||||
/* timespec_boxed_copy_func
|
||||
/* time64_boxed_copy_func
|
||||
static gpointer
|
||||
timespec_boxed_copy_func( gpointer in_timespec )// Local: 0:1:0
|
||||
time64_boxed_copy_func( gpointer in_time64 )// Local: 0:1:0
|
||||
*/
|
||||
/* static void
|
||||
test_timespec_boxed_copy_func (void)
|
||||
test_time64_boxed_copy_func (void)
|
||||
{
|
||||
}*/
|
||||
/* timespec_boxed_free_func
|
||||
/* time64_boxed_free_func
|
||||
static void
|
||||
timespec_boxed_free_func( gpointer in_timespec )// Local: 0:1:0
|
||||
time64_boxed_free_func( gpointer in_time64 )// Local: 0:1:0
|
||||
*/
|
||||
/* static void
|
||||
test_timespec_boxed_free_func (void)
|
||||
test_time64_boxed_free_func (void)
|
||||
{
|
||||
}*/
|
||||
// Not Used
|
||||
/* timespec_get_type
|
||||
/* time64_get_type
|
||||
GType
|
||||
timespec_get_type( void )// Local: 0:0:0
|
||||
time64_get_type( void )// Local: 0:0:0
|
||||
*/
|
||||
|
||||
|
||||
@ -2234,12 +1895,7 @@ test_suite_gnc_date (void)
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc date string to dateformat", test_gnc_date_string_to_dateformat);
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc date monthformat to string", test_gnc_date_monthformat_to_string);
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc date string to monthformat", test_gnc_date_string_to_monthformat);
|
||||
GNC_TEST_ADD_FUNC (suitename, "timespec normalize", test_timespec_normalize);
|
||||
GNC_TEST_ADD_FUNC (suitename, "timespec equal", test_timespec_equal);
|
||||
GNC_TEST_ADD_FUNC (suitename, "timespec cmp", test_timespec_cmp);
|
||||
GNC_TEST_ADD_FUNC (suitename, "timespec diff", test_timespec_diff);
|
||||
GNC_TEST_ADD_FUNC (suitename, "timespec abs", test_timespec_abs);
|
||||
GNC_TEST_ADD_FUNC (suitename, "timespecCanonicalDayTime", test_timespecCanonicalDayTime);
|
||||
GNC_TEST_ADD_FUNC (suitename, "time64CanonicalDayTime", test_time64CanonicalDayTime);
|
||||
GNC_TEST_ADD_FUNC (suitename, "date get last mday", test_gnc_date_get_last_mday);
|
||||
GNC_TEST_ADD_FUNC (suitename, "qof date format set", test_qof_date_format_set);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "qof date completion set", test_qof_date_completion_set);
|
||||
@ -2247,7 +1903,6 @@ test_suite_gnc_date (void)
|
||||
GNC_TEST_ADD_FUNC (suitename, "qof print date buff", test_qof_print_date_buff);
|
||||
GNC_TEST_ADD_FUNC (suitename, "qof print gdate", test_qof_print_gdate);
|
||||
GNC_TEST_ADD_FUNC (suitename, "qof print date", test_qof_print_date);
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc print date", test_gnc_print_date);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "floordiv", test_floordiv);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "qof scan date internal", test_qof_scan_date_internal);
|
||||
GNC_TEST_ADD_FUNC (suitename, "qof scan date", test_qof_scan_date);
|
||||
@ -2258,19 +1913,15 @@ test_suite_gnc_date (void)
|
||||
// GNC_TEST_ADD_FUNC (suitename, "qof strftime", test_qof_strftime);
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc_date_timestamp", test_gnc_date_timestamp);
|
||||
GNC_TEST_ADD (suitename, "gnc iso8601 to time64 gmt", FixtureA, NULL, setup, test_gnc_iso8601_to_time64_gmt, NULL);
|
||||
GNC_TEST_ADD (suitename, "gnc timespec to iso8601 buff", FixtureA, NULL, setup, test_gnc_timespec_to_iso8601_buff, NULL);
|
||||
GNC_TEST_ADD (suitename, "gnc timespec2dmy", FixtureA, NULL, setup, test_gnc_timespec2dmy, NULL);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "gnc dmy2timespec internal", test_gnc_dmy2timespec_internal);
|
||||
GNC_TEST_ADD (suitename, "gnc time64 to iso8601 buff", FixtureA, NULL, setup, test_gnc_time64_to_iso8601_buff, NULL);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "gnc dmy2time64 internal", test_gnc_dmy2time64_internal);
|
||||
|
||||
GNC_TEST_ADD (suitename, "gnc dmy2timespec", FixtureB, NULL, setup_begin, test_gnc_dmy2timespec, NULL);
|
||||
GNC_TEST_ADD (suitename, "gnc dmy2timespec end", FixtureB, NULL, setup_end, test_gnc_dmy2timespec_end, NULL);
|
||||
GNC_TEST_ADD (suitename, "gnc dmy2timespec Neutral", FixtureB, NULL, setup_neutral, test_gnc_dmy2timespec_neutral, NULL);
|
||||
GNC_TEST_ADD (suitename, "gnc dmy2time64", FixtureB, NULL, setup_begin, test_gnc_dmy2time64, NULL);
|
||||
GNC_TEST_ADD (suitename, "gnc dmy2time64 end", FixtureB, NULL, setup_end, test_gnc_dmy2time64_end, NULL);
|
||||
GNC_TEST_ADD (suitename, "gnc dmy2time64 Neutral", FixtureB, NULL, setup_neutral, test_gnc_dmy2time64_neutral, NULL);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "gnc timezone", test_gnc_timezone);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "timespecFromTime t", test_timespecFromtime64);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "timespec now", test_timespec_now);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "timespecToTime t", test_timespecTotime64);
|
||||
GNC_TEST_ADD (suitename, "timespec to gdate", FixtureA, NULL, setup, test_timespec_to_gdate, NULL);
|
||||
GNC_TEST_ADD (suitename, "gdate to timespec", FixtureB, NULL, setup_neutral, test_gdate_to_timespec, NULL);
|
||||
GNC_TEST_ADD (suitename, "time64 to gdate", FixtureA, NULL, setup, test_time64_to_gdate, NULL);
|
||||
GNC_TEST_ADD (suitename, "gdate to time64", FixtureB, NULL, setup_neutral, test_gdate_to_time64, NULL);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "gnc tm get day start", test_gnc_tm_get_day_start);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "gnc tm get day end", test_gnc_tm_get_day_end);
|
||||
GNC_TEST_ADD (suitename, "gnc time64 get day start", FixtureA, NULL, setup, test_gnc_time64_get_day_start, NULL);
|
||||
@ -2279,7 +1930,7 @@ test_suite_gnc_date (void)
|
||||
// GNC_TEST_ADD_FUNC (suitename, "gnc timet get today start", test_gnc_time64_get_today_start);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "gnc timet get today end", test_gnc_time64_get_today_end);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "gnc dow abbrev", test_gnc_dow_abbrev);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "timespec boxed copy func", test_timespec_boxed_copy_func);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "timespec boxed free func", test_timespec_boxed_free_func);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "time64 boxed copy func", test_time64_boxed_copy_func);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "time64 boxed free func", test_time64_boxed_free_func);
|
||||
g_time_zone_unref(tz);
|
||||
}
|
||||
|
@ -55,14 +55,14 @@ TEST (KvpValueTest, Equality)
|
||||
v2 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {guid_copy (guid)}};
|
||||
EXPECT_EQ (compare (*v1, *v2), 0);
|
||||
|
||||
v1 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {timespec_now ()}};
|
||||
v1 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {gnc_time(nullptr)}};
|
||||
v2 = std::unique_ptr<KvpValueImpl> {new KvpValueImpl {*v1}};
|
||||
EXPECT_EQ (compare (*v1, *v2), 0);
|
||||
}
|
||||
|
||||
TEST (KvpValueTest, Add)
|
||||
{
|
||||
auto v3 = new KvpValueImpl {timespec_now ()};
|
||||
auto v3 = new KvpValueImpl {gnc_time(nullptr)};
|
||||
auto v4 = new KvpValueImpl {*v3};
|
||||
auto new_one = v3->add (v4);
|
||||
EXPECT_NE (new_one, v3);
|
||||
|
@ -194,7 +194,7 @@ test_instance_new_destroy( void )
|
||||
QofInstance *inst;
|
||||
QofInstanceClass *klass;
|
||||
/* test var */
|
||||
Timespec *timespec_priv;
|
||||
Time64 *time_priv;
|
||||
const char *msg1 = "qof_instance_get_collection: assertion 'QOF_IS_INSTANCE(ptr)' failed";
|
||||
const char *msg2 = "qof_instance_get_editlevel: assertion 'QOF_IS_INSTANCE(ptr)' failed";
|
||||
const char *msg3 = "qof_instance_get_destroying: assertion 'QOF_IS_INSTANCE(ptr)' failed";
|
||||
@ -217,9 +217,8 @@ test_instance_new_destroy( void )
|
||||
g_assert( !qof_instance_get_collection( inst ) );
|
||||
g_assert( qof_instance_get_book( inst ) == NULL );
|
||||
g_assert( inst->kvp_data );
|
||||
g_object_get( inst, "last-update", ×pec_priv, NULL);
|
||||
g_assert_cmpint( timespec_priv->tv_sec, == , 0 );
|
||||
g_assert_cmpint( timespec_priv->tv_nsec, == , -1 );
|
||||
g_object_get( inst, "last-update", &time_priv, NULL);
|
||||
g_assert_cmpint( time_priv->t, == , 0 );
|
||||
g_assert_cmpint( qof_instance_get_editlevel( inst ), == , 0 );
|
||||
g_assert( !qof_instance_get_destroying( inst ) );
|
||||
g_assert( !qof_instance_get_dirty_flag( inst ) );
|
||||
@ -311,7 +310,7 @@ test_instance_version_cmp( void )
|
||||
{
|
||||
QofInstance *left, *right;
|
||||
int result;
|
||||
Timespec timespec_left, timespec_right;
|
||||
time64 time_left = 0, time_right = 1;
|
||||
|
||||
/* set up*/
|
||||
left = static_cast<QofInstance*>(g_object_new( QOF_TYPE_INSTANCE, NULL ));
|
||||
@ -330,48 +329,24 @@ test_instance_version_cmp( void )
|
||||
g_assert_cmpint( result, == , 1 );
|
||||
|
||||
g_test_message( "Test left tv_sec lesser than right" );
|
||||
timespec_left.tv_sec = 0;
|
||||
timespec_right.tv_sec = 1;
|
||||
qof_instance_set_last_update( left, timespec_left );
|
||||
qof_instance_set_last_update( right, timespec_right );
|
||||
qof_instance_set_last_update( left, time_left );
|
||||
qof_instance_set_last_update( right, time_right );
|
||||
result = qof_instance_version_cmp( left, right );
|
||||
g_assert_cmpint( result, == , -1 );
|
||||
|
||||
g_test_message( "Test right tv_sec lesser than left" );
|
||||
timespec_left.tv_sec = 1;
|
||||
timespec_right.tv_sec = 0;
|
||||
qof_instance_set_last_update( left, timespec_left );
|
||||
qof_instance_set_last_update( right, timespec_right );
|
||||
result = qof_instance_version_cmp( left, right );
|
||||
g_assert_cmpint( result, == , 1 );
|
||||
|
||||
g_test_message( "Test left tv_nsec lesser than right" );
|
||||
timespec_left.tv_sec = 1;
|
||||
timespec_left.tv_nsec = 0;
|
||||
timespec_right.tv_sec = 1;
|
||||
timespec_right.tv_nsec = 1;
|
||||
qof_instance_set_last_update( left, timespec_left );
|
||||
qof_instance_set_last_update( right, timespec_right );
|
||||
result = qof_instance_version_cmp( left, right );
|
||||
g_assert_cmpint( result, == , -1 );
|
||||
|
||||
g_test_message( "Test right tv_sec lesser than left" );
|
||||
timespec_left.tv_sec = 1;
|
||||
timespec_left.tv_nsec = 1;
|
||||
timespec_right.tv_sec = 1;
|
||||
timespec_right.tv_nsec = 0;
|
||||
qof_instance_set_last_update( left, timespec_left );
|
||||
qof_instance_set_last_update( right, timespec_right );
|
||||
time_left = 1;
|
||||
time_right = 0;
|
||||
qof_instance_set_last_update( left, time_left );
|
||||
qof_instance_set_last_update( right, time_right );
|
||||
result = qof_instance_version_cmp( left, right );
|
||||
g_assert_cmpint( result, == , 1 );
|
||||
|
||||
g_test_message( "Test both equal" );
|
||||
timespec_left.tv_sec = 1;
|
||||
timespec_left.tv_nsec = 1;
|
||||
timespec_right.tv_sec = 1;
|
||||
timespec_right.tv_nsec = 1;
|
||||
qof_instance_set_last_update( left, timespec_left );
|
||||
qof_instance_set_last_update( right, timespec_right );
|
||||
time_left = 1;
|
||||
time_right = 1;
|
||||
qof_instance_set_last_update( left, time_left );
|
||||
qof_instance_set_last_update( right, time_right );
|
||||
result = qof_instance_version_cmp( left, right );
|
||||
g_assert_cmpint( result, == , 0 );
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user