mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 795031 - 3.0 Crashes on loading when opening 2.6.19 file
This commit is contained in:
parent
4aadfbe636
commit
c71204628d
@ -113,7 +113,7 @@ gnc_search_date_class_init (GNCSearchDateClass *klass)
|
|||||||
static void
|
static void
|
||||||
gnc_search_date_init (GNCSearchDate *o)
|
gnc_search_date_init (GNCSearchDate *o)
|
||||||
{
|
{
|
||||||
o->ts.tv_sec = gnc_time (NULL);
|
o->tt = gnc_time (NULL);
|
||||||
o->how = QOF_COMPARE_LT;
|
o->how = QOF_COMPARE_LT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,12 +148,12 @@ gnc_search_date_new (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_search_date_set_date (GNCSearchDate *fi, Timespec ts)
|
gnc_search_date_set_date (GNCSearchDate *fi, time64 tt)
|
||||||
{
|
{
|
||||||
g_return_if_fail (fi);
|
g_return_if_fail (fi);
|
||||||
g_return_if_fail (IS_GNCSEARCH_DATE (fi));
|
g_return_if_fail (IS_GNCSEARCH_DATE (fi));
|
||||||
|
|
||||||
fi->ts = ts;
|
fi->tt = tt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -181,7 +181,7 @@ gncs_validate (GNCSearchCoreType *fe)
|
|||||||
static void
|
static void
|
||||||
date_changed (GNCDateEdit *date_edit, GNCSearchDate *fe)
|
date_changed (GNCDateEdit *date_edit, GNCSearchDate *fe)
|
||||||
{
|
{
|
||||||
fe->ts = gnc_date_edit_get_date_ts (date_edit);
|
fe->tt = gnc_date_edit_get_date (date_edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
@ -251,7 +251,7 @@ gncs_get_widget (GNCSearchCoreType *fe)
|
|||||||
gtk_box_pack_start (GTK_BOX (box), menu, FALSE, FALSE, 3);
|
gtk_box_pack_start (GTK_BOX (box), menu, FALSE, FALSE, 3);
|
||||||
|
|
||||||
/* Build and connect the date entry window */
|
/* Build and connect the date entry window */
|
||||||
entry = gnc_date_edit_new_ts (fi->ts, FALSE, FALSE);
|
entry = gnc_date_edit_new (fi->tt, FALSE, FALSE);
|
||||||
g_signal_connect (G_OBJECT (entry), "date_changed", G_CALLBACK (date_changed), fe);
|
g_signal_connect (G_OBJECT (entry), "date_changed", G_CALLBACK (date_changed), fe);
|
||||||
gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 3);
|
gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 3);
|
||||||
g_object_ref (entry);
|
g_object_ref (entry);
|
||||||
@ -272,9 +272,9 @@ static QofQueryPredData* gncs_get_predicate (GNCSearchCoreType *fe)
|
|||||||
/* Make sure we actually use the currently-entered date */
|
/* Make sure we actually use the currently-entered date */
|
||||||
priv = _PRIVATE(fi);
|
priv = _PRIVATE(fi);
|
||||||
if (priv->entry)
|
if (priv->entry)
|
||||||
fi->ts = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (priv->entry));
|
fi->tt = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->entry));
|
||||||
|
|
||||||
return qof_query_date_predicate (fi->how, QOF_DATE_MATCH_NORMAL, fi->ts);
|
return qof_query_date_predicate (fi->how, QOF_DATE_MATCH_NORMAL, fi->tt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GNCSearchCoreType *gncs_clone(GNCSearchCoreType *fe)
|
static GNCSearchCoreType *gncs_clone(GNCSearchCoreType *fe)
|
||||||
@ -285,7 +285,7 @@ static GNCSearchCoreType *gncs_clone(GNCSearchCoreType *fe)
|
|||||||
g_return_val_if_fail (IS_GNCSEARCH_DATE (fse), NULL);
|
g_return_val_if_fail (IS_GNCSEARCH_DATE (fse), NULL);
|
||||||
|
|
||||||
se = gnc_search_date_new ();
|
se = gnc_search_date_new ();
|
||||||
gnc_search_date_set_date (se, fse->ts);
|
gnc_search_date_set_date (se, fse->tt);
|
||||||
gnc_search_date_set_how (se, fse->how);
|
gnc_search_date_set_how (se, fse->how);
|
||||||
|
|
||||||
return (GNCSearchCoreType *)se;
|
return (GNCSearchCoreType *)se;
|
||||||
|
@ -38,8 +38,8 @@ struct _GNCSearchDate
|
|||||||
{
|
{
|
||||||
GNCSearchCoreType parent;
|
GNCSearchCoreType parent;
|
||||||
|
|
||||||
QofQueryCompare how;
|
QofQueryCompare how;
|
||||||
Timespec ts;
|
time64 tt;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GNCSearchDateClass
|
struct _GNCSearchDateClass
|
||||||
@ -55,7 +55,7 @@ GType gnc_search_date_get_type (void);
|
|||||||
GNCSearchDate *gnc_search_date_new (void);
|
GNCSearchDate *gnc_search_date_new (void);
|
||||||
|
|
||||||
/* methods */
|
/* methods */
|
||||||
void gnc_search_date_set_date (GNCSearchDate *fi, Timespec ts);
|
void gnc_search_date_set_date (GNCSearchDate *fi, time64 tt);
|
||||||
void gnc_search_date_set_how (GNCSearchDate *fi, QofQueryCompare how);
|
void gnc_search_date_set_how (GNCSearchDate *fi, QofQueryCompare how);
|
||||||
|
|
||||||
#endif /* ! _GNCSEARCH_DATE_H */
|
#endif /* ! _GNCSEARCH_DATE_H */
|
||||||
|
@ -149,7 +149,6 @@ get_num_xactions_before_date(QofBook *book, time64 close_date)
|
|||||||
QofQuery *q;
|
QofQuery *q;
|
||||||
GSList *param;
|
GSList *param;
|
||||||
QofQueryPredData *pred;
|
QofQueryPredData *pred;
|
||||||
Timespec ts;
|
|
||||||
GList *res, *n;
|
GList *res, *n;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
@ -159,8 +158,7 @@ get_num_xactions_before_date(QofBook *book, time64 close_date)
|
|||||||
|
|
||||||
/* Look for transactions earlier than the closing date */
|
/* Look for transactions earlier than the closing date */
|
||||||
param = g_slist_prepend (NULL, TRANS_DATE_POSTED);
|
param = g_slist_prepend (NULL, TRANS_DATE_POSTED);
|
||||||
timespecFromTime64 (&ts, close_date);
|
pred = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, close_date);
|
||||||
pred = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, ts);
|
|
||||||
qof_query_add_term (q, param, pred, QOF_QUERY_FIRST_TERM);
|
qof_query_add_term (q, param, pred, QOF_QUERY_FIRST_TERM);
|
||||||
|
|
||||||
/* Run the query, find how many transactions there are */
|
/* Run the query, find how many transactions there are */
|
||||||
|
@ -3323,7 +3323,6 @@ gnc_invoice_show_docs_due (GtkWindow *parent, QofBook *book, double days_in_adva
|
|||||||
gchar *message, *title;
|
gchar *message, *title;
|
||||||
DialogQueryView *dialog;
|
DialogQueryView *dialog;
|
||||||
gint len;
|
gint len;
|
||||||
Timespec ts;
|
|
||||||
static GList *param_list = NULL;
|
static GList *param_list = NULL;
|
||||||
static GNCDisplayViewButton vendorbuttons[] =
|
static GNCDisplayViewButton vendorbuttons[] =
|
||||||
{
|
{
|
||||||
@ -3413,9 +3412,7 @@ gnc_invoice_show_docs_due (GtkWindow *parent, QofBook *book, double days_in_adva
|
|||||||
days_in_advance = 0;
|
days_in_advance = 0;
|
||||||
end_date += days_in_advance * 60 * 60 * 24;
|
end_date += days_in_advance * 60 * 60 * 24;
|
||||||
|
|
||||||
ts.tv_sec = (gint64) end_date;
|
pred_data = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, end_date);
|
||||||
ts.tv_nsec = 0;
|
|
||||||
pred_data = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, ts);
|
|
||||||
qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_DUE), pred_data, QOF_QUERY_AND);
|
qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_DUE), pred_data, QOF_QUERY_AND);
|
||||||
|
|
||||||
res = qof_query_run(q);
|
res = qof_query_run(q);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "dialog-utils.h"
|
#include "dialog-utils.h"
|
||||||
#include "gnc-component-manager.h"
|
#include "gnc-component-manager.h"
|
||||||
@ -125,7 +126,7 @@ static void gnc_ui_to_order (OrderWindow *ow, GncOrder *order)
|
|||||||
GtkTextBuffer* text_buffer;
|
GtkTextBuffer* text_buffer;
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
Timespec ts;
|
time64 tt;
|
||||||
|
|
||||||
/* Do nothing if this is view only */
|
/* Do nothing if this is view only */
|
||||||
if (ow->dialog_type == VIEW_ORDER)
|
if (ow->dialog_type == VIEW_ORDER)
|
||||||
@ -145,8 +146,8 @@ static void gnc_ui_to_order (OrderWindow *ow, GncOrder *order)
|
|||||||
gncOrderSetReference (order, gtk_editable_get_chars
|
gncOrderSetReference (order, gtk_editable_get_chars
|
||||||
(GTK_EDITABLE (ow->ref_entry), 0, -1));
|
(GTK_EDITABLE (ow->ref_entry), 0, -1));
|
||||||
|
|
||||||
ts = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ow->opened_date));
|
tt = gnc_date_edit_get_date (GNC_DATE_EDIT (ow->opened_date));
|
||||||
gncOrderSetDateOpened (order, ts);
|
gncOrderSetDateOpened (order, tt);
|
||||||
|
|
||||||
if (ow->active_check)
|
if (ow->active_check)
|
||||||
gncOrderSetActive (order, gtk_toggle_button_get_active
|
gncOrderSetActive (order, gtk_toggle_button_get_active
|
||||||
@ -260,7 +261,7 @@ gnc_order_window_close_order_cb (GtkWidget *widget, gpointer data)
|
|||||||
GList *entries;
|
GList *entries;
|
||||||
char *message, *label;
|
char *message, *label;
|
||||||
gboolean non_inv = FALSE;
|
gboolean non_inv = FALSE;
|
||||||
Timespec ts;
|
Timespec ts = {gnc_time (NULL), 0};
|
||||||
|
|
||||||
/* Make sure the order is ok */
|
/* Make sure the order is ok */
|
||||||
if (!gnc_order_window_verify_ok (ow))
|
if (!gnc_order_window_verify_ok (ow))
|
||||||
@ -309,11 +310,10 @@ gnc_order_window_close_order_cb (GtkWidget *widget, gpointer data)
|
|||||||
message = _("Do you really want to close the order?");
|
message = _("Do you really want to close the order?");
|
||||||
label = _("Close Date");
|
label = _("Close Date");
|
||||||
|
|
||||||
timespecFromTime64 (&ts, gnc_time (NULL));
|
|
||||||
if (!gnc_dialog_date_close_parented (ow->dialog, message, label, TRUE, &ts))
|
if (!gnc_dialog_date_close_parented (ow->dialog, message, label, TRUE, &ts))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gncOrderSetDateClosed (order, ts);
|
gncOrderSetDateClosed (order, ts.tv_nsec);
|
||||||
|
|
||||||
/* save it off */
|
/* save it off */
|
||||||
gnc_order_window_ok_save (ow);
|
gnc_order_window_ok_save (ow);
|
||||||
@ -461,7 +461,7 @@ gnc_order_update_window (OrderWindow *ow)
|
|||||||
{
|
{
|
||||||
GtkTextBuffer* text_buffer;
|
GtkTextBuffer* text_buffer;
|
||||||
const char *string;
|
const char *string;
|
||||||
Timespec ts, ts_zero = {0, 0};
|
time64 tt;
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (ow->ref_entry),
|
gtk_entry_set_text (GTK_ENTRY (ow->ref_entry),
|
||||||
gncOrderGetReference (order));
|
gncOrderGetReference (order));
|
||||||
@ -470,23 +470,23 @@ gnc_order_update_window (OrderWindow *ow)
|
|||||||
text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(ow->notes_text));
|
text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(ow->notes_text));
|
||||||
gtk_text_buffer_set_text (text_buffer, string, -1);
|
gtk_text_buffer_set_text (text_buffer, string, -1);
|
||||||
|
|
||||||
ts = gncOrderGetDateOpened (order);
|
tt = gncOrderGetDateOpened (order);
|
||||||
if (timespec_equal (&ts, &ts_zero))
|
if (tt == INT64_MAX)
|
||||||
{
|
{
|
||||||
gnc_date_edit_set_time (GNC_DATE_EDIT (ow->opened_date),
|
gnc_date_edit_set_time (GNC_DATE_EDIT (ow->opened_date),
|
||||||
gnc_time (NULL));
|
gnc_time (NULL));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ow->opened_date), ts);
|
gnc_date_edit_set_time (GNC_DATE_EDIT (ow->opened_date), tt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this is a "New Order Window" we can stop here! */
|
/* If this is a "New Order Window" we can stop here! */
|
||||||
if (ow->dialog_type == NEW_ORDER)
|
if (ow->dialog_type == NEW_ORDER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ts = gncOrderGetDateClosed (order);
|
tt = gncOrderGetDateClosed (order);
|
||||||
if (timespec_equal (&ts, &ts_zero))
|
if (tt == INT64_MAX)
|
||||||
{
|
{
|
||||||
gnc_date_edit_set_time (GNC_DATE_EDIT (ow->closed_date),
|
gnc_date_edit_set_time (GNC_DATE_EDIT (ow->closed_date),
|
||||||
gnc_time (NULL));
|
gnc_time (NULL));
|
||||||
@ -494,7 +494,7 @@ gnc_order_update_window (OrderWindow *ow)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ow->closed_date), ts);
|
gnc_date_edit_set_time (GNC_DATE_EDIT (ow->closed_date), tt);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow->active_check),
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ow->active_check),
|
||||||
@ -770,11 +770,8 @@ gnc_ui_order_edit (GtkWindow *parent, GncOrder *order)
|
|||||||
if (!order) return NULL;
|
if (!order) return NULL;
|
||||||
|
|
||||||
type = EDIT_ORDER;
|
type = EDIT_ORDER;
|
||||||
{
|
if (gncOrderGetDateClosed (order) == INT64_MAX)
|
||||||
Timespec ts = gncOrderGetDateClosed (order);
|
type = VIEW_ORDER;
|
||||||
if (ts.tv_sec || ts.tv_nsec)
|
|
||||||
type = VIEW_ORDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
ow = gnc_order_new_window (parent, gncOrderGetBook(order), type, order,
|
ow = gnc_order_new_window (parent, gncOrderGetBook(order), type, order,
|
||||||
gncOrderGetOwner (order));
|
gncOrderGetOwner (order));
|
||||||
|
@ -857,7 +857,7 @@ convert_query_term_to_sql (const GncSqlBackend* sql_be, const gchar* fieldName,
|
|||||||
{
|
{
|
||||||
query_date_t date_data = (query_date_t)pPredData;
|
query_date_t date_data = (query_date_t)pPredData;
|
||||||
|
|
||||||
GncDateTime time(date_data->date.tv_sec);
|
GncDateTime time(date_data->date);
|
||||||
sql << time.format_zulu ("%Y-%m-%d %H:%M:%S");
|
sql << time.format_zulu ("%Y-%m-%d %H:%M:%S");
|
||||||
}
|
}
|
||||||
else if (strcmp (pPredData->type_name, QOF_TYPE_INT32) == 0)
|
else if (strcmp (pPredData->type_name, QOF_TYPE_INT32) == 0)
|
||||||
|
@ -75,7 +75,7 @@ static xmlNodePtr
|
|||||||
order_dom_tree_create (GncOrder* order)
|
order_dom_tree_create (GncOrder* order)
|
||||||
{
|
{
|
||||||
xmlNodePtr ret;
|
xmlNodePtr ret;
|
||||||
Timespec ts;
|
time64 tt;
|
||||||
|
|
||||||
ret = xmlNewNode (NULL, BAD_CAST gnc_order_string);
|
ret = xmlNewNode (NULL, BAD_CAST gnc_order_string);
|
||||||
xmlSetProp (ret, BAD_CAST "version", BAD_CAST order_version_string);
|
xmlSetProp (ret, BAD_CAST "version", BAD_CAST order_version_string);
|
||||||
@ -89,12 +89,12 @@ order_dom_tree_create (GncOrder* order)
|
|||||||
xmlAddChild (ret, gnc_owner_to_dom_tree (order_owner_string,
|
xmlAddChild (ret, gnc_owner_to_dom_tree (order_owner_string,
|
||||||
gncOrderGetOwner (order)));
|
gncOrderGetOwner (order)));
|
||||||
|
|
||||||
ts = gncOrderGetDateOpened (order);
|
tt = gncOrderGetDateOpened (order);
|
||||||
xmlAddChild (ret, time64_to_dom_tree (order_opened_string, ts.tv_sec));
|
xmlAddChild (ret, time64_to_dom_tree (order_opened_string, tt));
|
||||||
|
|
||||||
ts = gncOrderGetDateClosed (order);
|
tt = gncOrderGetDateClosed (order);
|
||||||
if (ts.tv_sec)
|
if (tt != INT64_MAX)
|
||||||
xmlAddChild (ret, time64_to_dom_tree (order_closed_string, ts.tv_sec));
|
xmlAddChild (ret, time64_to_dom_tree (order_closed_string, tt));
|
||||||
|
|
||||||
maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order));
|
maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order));
|
||||||
maybe_add_string (ret, order_reference_string, gncOrderGetReference (order));
|
maybe_add_string (ret, order_reference_string, gncOrderGetReference (order));
|
||||||
@ -131,13 +131,12 @@ set_string (xmlNodePtr node, GncOrder* order,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
set_timespec (xmlNodePtr node, GncOrder* order,
|
set_time64 (xmlNodePtr node, GncOrder* order,
|
||||||
void (*func) (GncOrder* order, Timespec ts))
|
void (*func) (GncOrder* order, time64 tt))
|
||||||
{
|
{
|
||||||
time64 time = dom_tree_to_time64 (node);
|
time64 time = dom_tree_to_time64 (node);
|
||||||
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
|
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
|
||||||
Timespec ts {time, 0};
|
func (order, time);
|
||||||
func (order, ts);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +193,7 @@ order_opened_handler (xmlNodePtr node, gpointer order_pdata)
|
|||||||
{
|
{
|
||||||
struct order_pdata* pdata = static_cast<decltype (pdata)> (order_pdata);
|
struct order_pdata* pdata = static_cast<decltype (pdata)> (order_pdata);
|
||||||
|
|
||||||
return set_timespec (node, pdata->order, gncOrderSetDateOpened);
|
return set_time64 (node, pdata->order, gncOrderSetDateOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -202,7 +201,7 @@ order_closed_handler (xmlNodePtr node, gpointer order_pdata)
|
|||||||
{
|
{
|
||||||
struct order_pdata* pdata = static_cast<decltype (pdata)> (order_pdata);
|
struct order_pdata* pdata = static_cast<decltype (pdata)> (order_pdata);
|
||||||
|
|
||||||
return set_timespec (node, pdata->order, gncOrderSetDateClosed);
|
return set_time64 (node, pdata->order, gncOrderSetDateClosed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -380,9 +380,9 @@ xaccQueryAddNumericMatch (QofQuery *q, gnc_numeric amount, QofNumericMatch sign,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccQueryAddDateMatchTS (QofQuery * q,
|
xaccQueryAddDateMatchTT (QofQuery * q,
|
||||||
gboolean use_start, Timespec sts,
|
gboolean use_start, time64 stt,
|
||||||
gboolean use_end, Timespec ets,
|
gboolean use_end, time64 ett,
|
||||||
QofQueryOp op)
|
QofQueryOp op)
|
||||||
{
|
{
|
||||||
QofQuery *tmp_q = NULL;
|
QofQuery *tmp_q = NULL;
|
||||||
@ -396,7 +396,7 @@ xaccQueryAddDateMatchTS (QofQuery * q,
|
|||||||
|
|
||||||
if (use_start)
|
if (use_start)
|
||||||
{
|
{
|
||||||
pred_data = qof_query_date_predicate (QOF_COMPARE_GTE, QOF_DATE_MATCH_NORMAL, sts);
|
pred_data = qof_query_date_predicate (QOF_COMPARE_GTE, QOF_DATE_MATCH_NORMAL, stt);
|
||||||
if (!pred_data)
|
if (!pred_data)
|
||||||
{
|
{
|
||||||
qof_query_destroy (tmp_q);
|
qof_query_destroy (tmp_q);
|
||||||
@ -409,7 +409,7 @@ xaccQueryAddDateMatchTS (QofQuery * q,
|
|||||||
|
|
||||||
if (use_end)
|
if (use_end)
|
||||||
{
|
{
|
||||||
pred_data = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, ets);
|
pred_data = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, ett);
|
||||||
if (!pred_data)
|
if (!pred_data)
|
||||||
{
|
{
|
||||||
qof_query_destroy (tmp_q);
|
qof_query_destroy (tmp_q);
|
||||||
@ -425,16 +425,16 @@ xaccQueryAddDateMatchTS (QofQuery * q,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccQueryGetDateMatchTS (QofQuery * q,
|
xaccQueryGetDateMatchTT (QofQuery * q,
|
||||||
Timespec * sts,
|
time64 * stt,
|
||||||
Timespec * ets)
|
time64 * ett)
|
||||||
{
|
{
|
||||||
QofQueryPredData *term_data;
|
QofQueryPredData *term_data;
|
||||||
GSList *param_list;
|
GSList *param_list;
|
||||||
GSList *terms, *tmp;
|
GSList *terms, *tmp;
|
||||||
|
|
||||||
sts->tv_sec = sts->tv_nsec = 0;
|
*stt = 0;
|
||||||
ets->tv_sec = ets->tv_nsec = 0;
|
*ett = 0;
|
||||||
|
|
||||||
param_list = qof_query_build_param_list (SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
|
param_list = qof_query_build_param_list (SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
|
||||||
terms = qof_query_get_term_type (q, param_list);
|
terms = qof_query_get_term_type (q, param_list);
|
||||||
@ -444,9 +444,9 @@ xaccQueryGetDateMatchTS (QofQuery * q,
|
|||||||
{
|
{
|
||||||
term_data = tmp->data;
|
term_data = tmp->data;
|
||||||
if (term_data->how == QOF_COMPARE_GTE)
|
if (term_data->how == QOF_COMPARE_GTE)
|
||||||
qof_query_date_predicate_get_date(term_data, sts);
|
qof_query_date_predicate_get_date(term_data, stt);
|
||||||
if (term_data->how == QOF_COMPARE_LTE)
|
if (term_data->how == QOF_COMPARE_LTE)
|
||||||
qof_query_date_predicate_get_date(term_data, ets);
|
qof_query_date_predicate_get_date(term_data, ett);
|
||||||
}
|
}
|
||||||
g_slist_free(terms);
|
g_slist_free(terms);
|
||||||
}
|
}
|
||||||
@ -463,55 +463,13 @@ xaccQueryAddDateMatch(QofQuery * q,
|
|||||||
QofQueryOp op)
|
QofQueryOp op)
|
||||||
{
|
{
|
||||||
/* gcc -O3 will auto-inline this function, avoiding a call overhead */
|
/* gcc -O3 will auto-inline this function, avoiding a call overhead */
|
||||||
xaccQueryAddDateMatchTS (q, use_start,
|
xaccQueryAddDateMatchTT (q, use_start,
|
||||||
gnc_dmy2timespec(sday, smonth, syear),
|
gnc_dmy2time64(sday, smonth, syear),
|
||||||
use_end,
|
use_end,
|
||||||
gnc_dmy2timespec_end(eday, emonth, eyear),
|
gnc_dmy2time64_end(eday, emonth, eyear),
|
||||||
op);
|
op);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
* xaccQueryAddDateMatchTT
|
|
||||||
* Add a date filter to an existing query.
|
|
||||||
********************************************************************/
|
|
||||||
|
|
||||||
void
|
|
||||||
xaccQueryAddDateMatchTT(QofQuery * q,
|
|
||||||
gboolean use_start,
|
|
||||||
time64 stt,
|
|
||||||
gboolean use_end,
|
|
||||||
time64 ett,
|
|
||||||
QofQueryOp op)
|
|
||||||
{
|
|
||||||
Timespec sts;
|
|
||||||
Timespec ets;
|
|
||||||
|
|
||||||
sts.tv_sec = stt;
|
|
||||||
sts.tv_nsec = 0;
|
|
||||||
|
|
||||||
ets.tv_sec = ett;
|
|
||||||
ets.tv_nsec = 0;
|
|
||||||
|
|
||||||
/* gcc -O3 will auto-inline this function, avoiding a call overhead */
|
|
||||||
xaccQueryAddDateMatchTS (q, use_start, sts,
|
|
||||||
use_end, ets, op);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xaccQueryGetDateMatchTT (QofQuery * q,
|
|
||||||
time64 * stt,
|
|
||||||
time64 * ett)
|
|
||||||
{
|
|
||||||
Timespec sts;
|
|
||||||
Timespec ets;
|
|
||||||
|
|
||||||
xaccQueryGetDateMatchTS (q, &sts, &ets);
|
|
||||||
|
|
||||||
*stt = sts.tv_sec;
|
|
||||||
*ett = ets.tv_sec;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccQueryAddClearedMatch(QofQuery * q, cleared_match_t how, QofQueryOp op)
|
xaccQueryAddClearedMatch(QofQuery * q, cleared_match_t how, QofQueryOp op)
|
||||||
{
|
{
|
||||||
|
@ -154,17 +154,10 @@ void xaccQueryAddDateMatch(QofQuery * q, gboolean use_start,
|
|||||||
int sday, int smonth, int syear,
|
int sday, int smonth, int syear,
|
||||||
gboolean use_end, int eday, int emonth, int eyear,
|
gboolean use_end, int eday, int emonth, int eyear,
|
||||||
QofQueryOp op);
|
QofQueryOp op);
|
||||||
void xaccQueryAddDateMatchTS(QofQuery * q,
|
|
||||||
gboolean use_start, Timespec sts,
|
|
||||||
gboolean use_end, Timespec ets,
|
|
||||||
QofQueryOp op);
|
|
||||||
void xaccQueryAddDateMatchTT(QofQuery * q,
|
void xaccQueryAddDateMatchTT(QofQuery * q,
|
||||||
gboolean use_start, time64 stt,
|
gboolean use_start, time64 stt,
|
||||||
gboolean use_end, time64 ett,
|
gboolean use_end, time64 ett,
|
||||||
QofQueryOp op);
|
QofQueryOp op);
|
||||||
void xaccQueryGetDateMatchTS (QofQuery * q,
|
|
||||||
Timespec * sts,
|
|
||||||
Timespec * ets);
|
|
||||||
void xaccQueryGetDateMatchTT (QofQuery * q,
|
void xaccQueryGetDateMatchTT (QofQuery * q,
|
||||||
time64 * stt,
|
time64 * stt,
|
||||||
time64 * ett);
|
time64 * ett);
|
||||||
|
@ -150,7 +150,6 @@ the union is. The values of type are:
|
|||||||
PD_DATE : match a date range. Specify a start date and an end date.
|
PD_DATE : match a date range. Specify a start date and an end date.
|
||||||
|
|
||||||
Used in: xaccQueryAddDateMatch
|
Used in: xaccQueryAddDateMatch
|
||||||
xaccQueryAddDateMatchTS
|
|
||||||
xaccQueryAddDateMatchTT
|
xaccQueryAddDateMatchTT
|
||||||
|
|
||||||
-----------------------------------------------------------------
|
-----------------------------------------------------------------
|
||||||
|
@ -23,12 +23,16 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include "Recurrence.h"
|
#include "Recurrence.h"
|
||||||
#include "gnc-date.h"
|
#include "gnc-date.h"
|
||||||
#include "qof.h"
|
#include "qof.h"
|
||||||
#include "gnc-engine.h"
|
#include "gnc-engine.h"
|
||||||
#include "gnc-date.h"
|
#include "gnc-date.h"
|
||||||
#include "Account.h"
|
#include "Account.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#define LOG_MOD "gnc.engine.recurrence"
|
#define LOG_MOD "gnc.engine.recurrence"
|
||||||
static QofLogModule log_module = LOG_MOD;
|
static QofLogModule log_module = LOG_MOD;
|
||||||
@ -69,6 +73,12 @@ recurrenceGetDate(const Recurrence *r)
|
|||||||
return r ? r->start : invalid_gdate;
|
return r ? r->start : invalid_gdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time64
|
||||||
|
recurrenceGetTime(const Recurrence *r)
|
||||||
|
{
|
||||||
|
return r ? gdate_to_time64(r->start) : INT64_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
WeekendAdjust
|
WeekendAdjust
|
||||||
recurrenceGetWeekendAdjust(const Recurrence *r)
|
recurrenceGetWeekendAdjust(const Recurrence *r)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +108,7 @@ void recurrenceSet(Recurrence *r, guint16 mult, PeriodType pt,
|
|||||||
PeriodType recurrenceGetPeriodType(const Recurrence *r);
|
PeriodType recurrenceGetPeriodType(const Recurrence *r);
|
||||||
guint recurrenceGetMultiplier(const Recurrence *r);
|
guint recurrenceGetMultiplier(const Recurrence *r);
|
||||||
GDate recurrenceGetDate(const Recurrence *r);
|
GDate recurrenceGetDate(const Recurrence *r);
|
||||||
|
time64 recurrenceGetTime(const Recurrence *r);
|
||||||
WeekendAdjust recurrenceGetWeekendAdjust(const Recurrence *r);
|
WeekendAdjust recurrenceGetWeekendAdjust(const Recurrence *r);
|
||||||
|
|
||||||
/* Get the occurrence immediately after refDate.
|
/* Get the occurrence immediately after refDate.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "qof.h"
|
#include "qof.h"
|
||||||
|
|
||||||
@ -599,6 +600,13 @@ xaccSchedXactionGetStartDate(const SchedXaction *sx )
|
|||||||
return &sx->start_date;
|
return &sx->start_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time64
|
||||||
|
xaccSchedXactionGetStartDateTT(const SchedXaction *sx )
|
||||||
|
{
|
||||||
|
g_assert (sx);
|
||||||
|
return gdate_to_time64(sx->start_date);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart )
|
xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart )
|
||||||
{
|
{
|
||||||
@ -618,6 +626,25 @@ xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart )
|
|||||||
gnc_sx_commit_edit(sx);
|
gnc_sx_commit_edit(sx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xaccSchedXactionSetStartDateTT( SchedXaction *sx, const time64 newStart )
|
||||||
|
{
|
||||||
|
if ( newStart == INT64_MAX )
|
||||||
|
{
|
||||||
|
/* XXX: I reject the bad data - is this the right
|
||||||
|
* thing to do <rgmerk>.
|
||||||
|
* This warning is only human readable - the caller
|
||||||
|
* doesn't know the call failed. This is bad
|
||||||
|
*/
|
||||||
|
g_critical("Invalid Start Date");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gnc_sx_begin_edit(sx);
|
||||||
|
gnc_gdate_set_time64(&sx->start_date, newStart);
|
||||||
|
qof_instance_set_dirty(&sx->inst);
|
||||||
|
gnc_sx_commit_edit(sx);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
xaccSchedXactionHasEndDate( const SchedXaction *sx )
|
xaccSchedXactionHasEndDate( const SchedXaction *sx )
|
||||||
{
|
{
|
||||||
@ -662,6 +689,12 @@ xaccSchedXactionGetLastOccurDate(const SchedXaction *sx )
|
|||||||
return &sx->last_date;
|
return &sx->last_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time64
|
||||||
|
xaccSchedXactionGetLastOccurDateTT(const SchedXaction *sx )
|
||||||
|
{
|
||||||
|
return gdate_to_time64(sx->last_date);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccSchedXactionSetLastOccurDate(SchedXaction *sx, const GDate* new_last_occur)
|
xaccSchedXactionSetLastOccurDate(SchedXaction *sx, const GDate* new_last_occur)
|
||||||
{
|
{
|
||||||
@ -675,6 +708,21 @@ xaccSchedXactionSetLastOccurDate(SchedXaction *sx, const GDate* new_last_occur)
|
|||||||
gnc_sx_commit_edit(sx);
|
gnc_sx_commit_edit(sx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xaccSchedXactionSetLastOccurDateTT(SchedXaction *sx, time64 new_last_occur)
|
||||||
|
{
|
||||||
|
GDate last_occur;
|
||||||
|
g_return_if_fail (new_last_occur != INT64_MAX);
|
||||||
|
gnc_gdate_set_time64(&last_occur, new_last_occur);
|
||||||
|
if (g_date_valid(&sx->last_date)
|
||||||
|
&& g_date_compare(&sx->last_date, &last_occur) == 0)
|
||||||
|
return;
|
||||||
|
gnc_sx_begin_edit(sx);
|
||||||
|
sx->last_date = last_occur;
|
||||||
|
qof_instance_set_dirty(&sx->inst);
|
||||||
|
gnc_sx_commit_edit(sx);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
xaccSchedXactionHasOccurDef( const SchedXaction *sx )
|
xaccSchedXactionHasOccurDef( const SchedXaction *sx )
|
||||||
{
|
{
|
||||||
@ -1196,12 +1244,12 @@ SXRegister(void)
|
|||||||
(QofSetterFunc)xaccSchedXactionSetName
|
(QofSetterFunc)xaccSchedXactionSetName
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
GNC_SX_START_DATE, QOF_TYPE_DATE, (QofAccessFunc)xaccSchedXactionGetStartDate,
|
GNC_SX_START_DATE, QOF_TYPE_DATE, (QofAccessFunc)xaccSchedXactionGetStartDateTT,
|
||||||
(QofSetterFunc)xaccSchedXactionSetStartDate
|
(QofSetterFunc)xaccSchedXactionSetStartDateTT
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
GNC_SX_LAST_DATE, QOF_TYPE_DATE, (QofAccessFunc)xaccSchedXactionGetLastOccurDate,
|
GNC_SX_LAST_DATE, QOF_TYPE_DATE, (QofAccessFunc)xaccSchedXactionGetLastOccurDateTT,
|
||||||
(QofSetterFunc)xaccSchedXactionSetLastOccurDate
|
(QofSetterFunc)xaccSchedXactionSetLastOccurDateTT
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
GNC_SX_NUM_OCCUR, QOF_TYPE_INT64, (QofAccessFunc)xaccSchedXactionGetNumOccur,
|
GNC_SX_NUM_OCCUR, QOF_TYPE_INT64, (QofAccessFunc)xaccSchedXactionGetNumOccur,
|
||||||
|
@ -161,7 +161,9 @@ gchar *xaccSchedXactionGetName( const SchedXaction *sx );
|
|||||||
void xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName );
|
void xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName );
|
||||||
|
|
||||||
const GDate* xaccSchedXactionGetStartDate(const SchedXaction *sx );
|
const GDate* xaccSchedXactionGetStartDate(const SchedXaction *sx );
|
||||||
|
time64 xaccSchedXactionGetStartDateTT(const SchedXaction *sx );
|
||||||
void xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart );
|
void xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart );
|
||||||
|
void xaccSchedXactionSetStartDateTT( SchedXaction *sx, const time64 newStart );
|
||||||
|
|
||||||
int xaccSchedXactionHasEndDate( const SchedXaction *sx );
|
int xaccSchedXactionHasEndDate( const SchedXaction *sx );
|
||||||
/**
|
/**
|
||||||
@ -174,7 +176,9 @@ const GDate* xaccSchedXactionGetEndDate(const SchedXaction *sx );
|
|||||||
void xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate* newEnd );
|
void xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate* newEnd );
|
||||||
|
|
||||||
const GDate* xaccSchedXactionGetLastOccurDate(const SchedXaction *sx );
|
const GDate* xaccSchedXactionGetLastOccurDate(const SchedXaction *sx );
|
||||||
|
time64 xaccSchedXactionGetLastOccurDateTT(const SchedXaction *sx );
|
||||||
void xaccSchedXactionSetLastOccurDate( SchedXaction *sx, const GDate* newLastOccur );
|
void xaccSchedXactionSetLastOccurDate( SchedXaction *sx, const GDate* newLastOccur );
|
||||||
|
void xaccSchedXactionSetLastOccurDateTT( SchedXaction *sx, const time64 newLastOccur );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the scheduled transaction has a defined number of
|
* Returns true if the scheduled transaction has a defined number of
|
||||||
|
@ -2246,8 +2246,8 @@ gboolean xaccSplitRegister (void)
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
SPLIT_DATE_RECONCILED, QOF_TYPE_DATE,
|
SPLIT_DATE_RECONCILED, QOF_TYPE_DATE,
|
||||||
(QofAccessFunc)xaccSplitRetDateReconciledTS,
|
(QofAccessFunc)xaccSplitGetDateReconciled,
|
||||||
(QofSetterFunc)xaccSplitSetDateReconciledTS
|
(QofSetterFunc)xaccSplitSetDateReconciledSecs
|
||||||
},
|
},
|
||||||
|
|
||||||
/* d-* are deprecated query params, should not be used in new
|
/* d-* are deprecated query params, should not be used in new
|
||||||
|
@ -2990,17 +2990,17 @@ gboolean xaccTransRegister (void)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
TRANS_DATE_ENTERED, QOF_TYPE_DATE,
|
TRANS_DATE_ENTERED, QOF_TYPE_DATE,
|
||||||
(QofAccessFunc)xaccTransRetDateEnteredTS,
|
(QofAccessFunc)xaccTransRetDateEntered,
|
||||||
(QofSetterFunc)qofTransSetDateEnteredTS
|
(QofSetterFunc)xaccTransSetDateEnteredSecs
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
TRANS_DATE_POSTED, QOF_TYPE_DATE,
|
TRANS_DATE_POSTED, QOF_TYPE_DATE,
|
||||||
(QofAccessFunc)xaccTransRetDatePostedTS,
|
(QofAccessFunc)xaccTransRetDatePosted,
|
||||||
(QofSetterFunc)qofTransSetDatePostedTS
|
(QofSetterFunc)xaccTransSetDatePostedSecs
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
TRANS_DATE_DUE, QOF_TYPE_DATE,
|
TRANS_DATE_DUE, QOF_TYPE_DATE,
|
||||||
(QofAccessFunc)xaccTransRetDateDueTS, NULL
|
(QofAccessFunc)xaccTransRetDateDue, NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
TRANS_IMBALANCE, QOF_TYPE_NUMERIC,
|
TRANS_IMBALANCE, QOF_TYPE_NUMERIC,
|
||||||
|
@ -709,7 +709,7 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
|
|||||||
query_date_t pdata = (query_date_t) pd;
|
query_date_t pdata = (query_date_t) pd;
|
||||||
|
|
||||||
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
|
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
|
||||||
qt_scm = scm_cons (gnc_timespec2timepair (pdata->date), qt_scm);
|
qt_scm = scm_cons (scm_from_int64 (pdata->date), qt_scm);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_NUMERIC))
|
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_NUMERIC))
|
||||||
@ -841,7 +841,7 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
|
|||||||
else if (!g_strcmp0 (type, QOF_TYPE_DATE))
|
else if (!g_strcmp0 (type, QOF_TYPE_DATE))
|
||||||
{
|
{
|
||||||
QofDateMatch options;
|
QofDateMatch options;
|
||||||
Timespec date;
|
time64 date;
|
||||||
|
|
||||||
scm = SCM_CAR (qt_scm);
|
scm = SCM_CAR (qt_scm);
|
||||||
qt_scm = SCM_CDR (qt_scm);
|
qt_scm = SCM_CDR (qt_scm);
|
||||||
@ -853,7 +853,7 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
|
|||||||
qt_scm = SCM_CDR (qt_scm);
|
qt_scm = SCM_CDR (qt_scm);
|
||||||
if (scm_is_null (scm))
|
if (scm_is_null (scm))
|
||||||
break;
|
break;
|
||||||
date = gnc_timepair2timespec (scm);
|
date = scm_to_int64 (scm);
|
||||||
|
|
||||||
pd = qof_query_date_predicate (compare_how, options, date);
|
pd = qof_query_date_predicate (compare_how, options, date);
|
||||||
|
|
||||||
@ -1039,8 +1039,8 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
|||||||
{
|
{
|
||||||
gboolean use_start;
|
gboolean use_start;
|
||||||
gboolean use_end;
|
gboolean use_end;
|
||||||
Timespec start;
|
time64 start;
|
||||||
Timespec end;
|
time64 end;
|
||||||
|
|
||||||
/* use_start */
|
/* use_start */
|
||||||
if (scm_is_null (query_term_scm))
|
if (scm_is_null (query_term_scm))
|
||||||
@ -1059,7 +1059,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
|||||||
|
|
||||||
scm = SCM_CAR (query_term_scm);
|
scm = SCM_CAR (query_term_scm);
|
||||||
query_term_scm = SCM_CDR (query_term_scm);
|
query_term_scm = SCM_CDR (query_term_scm);
|
||||||
start = gnc_timepair2timespec (scm);
|
start = scm_to_int64 (scm);
|
||||||
|
|
||||||
/* use_end */
|
/* use_end */
|
||||||
if (scm_is_null (query_term_scm))
|
if (scm_is_null (query_term_scm))
|
||||||
@ -1075,9 +1075,9 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
|||||||
|
|
||||||
scm = SCM_CAR (query_term_scm);
|
scm = SCM_CAR (query_term_scm);
|
||||||
query_term_scm = SCM_CDR (query_term_scm);
|
query_term_scm = SCM_CDR (query_term_scm);
|
||||||
end = gnc_timepair2timespec (scm);
|
end = scm_to_int64 (scm);
|
||||||
|
|
||||||
xaccQueryAddDateMatchTS (q, use_start, start, use_end, end, QOF_QUERY_OR);
|
xaccQueryAddDateMatchTT (q, use_start, start, use_end, end, QOF_QUERY_OR);
|
||||||
|
|
||||||
ok = TRUE;
|
ok = TRUE;
|
||||||
|
|
||||||
|
@ -720,9 +720,9 @@ static guint gnc_budget_get_rec_mult(const GncBudget *bgt)
|
|||||||
{
|
{
|
||||||
return recurrenceGetMultiplier(&(GET_PRIVATE(bgt)->recurrence));
|
return recurrenceGetMultiplier(&(GET_PRIVATE(bgt)->recurrence));
|
||||||
}
|
}
|
||||||
static GDate gnc_budget_get_rec_date(const GncBudget *bgt)
|
static time64 gnc_budget_get_rec_time(const GncBudget *bgt)
|
||||||
{
|
{
|
||||||
return recurrenceGetDate(&(GET_PRIVATE(bgt)->recurrence));
|
return recurrenceGetTime(&(GET_PRIVATE(bgt)->recurrence));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register ourselves with the engine. */
|
/* Register ourselves with the engine. */
|
||||||
@ -754,7 +754,7 @@ gboolean gnc_budget_register (void)
|
|||||||
this is wrong. */
|
this is wrong. */
|
||||||
{
|
{
|
||||||
"recurrence_date", QOF_TYPE_DATE,
|
"recurrence_date", QOF_TYPE_DATE,
|
||||||
(QofAccessFunc) gnc_budget_get_rec_date, NULL
|
(QofAccessFunc) gnc_budget_get_rec_time, NULL
|
||||||
},
|
},
|
||||||
/* Signedness problem: Should be unsigned. */
|
/* Signedness problem: Should be unsigned. */
|
||||||
{
|
{
|
||||||
|
@ -3227,7 +3227,7 @@ gnc_pricedb_register (void)
|
|||||||
{
|
{
|
||||||
{ PRICE_COMMODITY, GNC_ID_COMMODITY, (QofAccessFunc)gnc_price_get_commodity, (QofSetterFunc)gnc_price_set_commodity },
|
{ PRICE_COMMODITY, GNC_ID_COMMODITY, (QofAccessFunc)gnc_price_get_commodity, (QofSetterFunc)gnc_price_set_commodity },
|
||||||
{ PRICE_CURRENCY, GNC_ID_COMMODITY, (QofAccessFunc)gnc_price_get_currency, (QofSetterFunc)gnc_price_set_currency },
|
{ PRICE_CURRENCY, GNC_ID_COMMODITY, (QofAccessFunc)gnc_price_get_currency, (QofSetterFunc)gnc_price_set_currency },
|
||||||
{ PRICE_DATE, QOF_TYPE_DATE, (QofAccessFunc)gnc_price_get_time, (QofSetterFunc)gnc_price_set_time },
|
{ PRICE_DATE, QOF_TYPE_DATE, (QofAccessFunc)gnc_price_get_time64, (QofSetterFunc)gnc_price_set_time64 },
|
||||||
{ PRICE_SOURCE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_source, (QofSetterFunc)gnc_price_set_source },
|
{ PRICE_SOURCE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_source, (QofSetterFunc)gnc_price_set_source },
|
||||||
{ PRICE_TYPE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_typestr, (QofSetterFunc)gnc_price_set_typestr },
|
{ PRICE_TYPE, QOF_TYPE_STRING, (QofAccessFunc)gnc_price_get_typestr, (QofSetterFunc)gnc_price_set_typestr },
|
||||||
{ PRICE_VALUE, QOF_TYPE_NUMERIC, (QofAccessFunc)gnc_price_get_value, (QofSetterFunc)gnc_price_set_value },
|
{ PRICE_VALUE, QOF_TYPE_NUMERIC, (QofAccessFunc)gnc_price_get_value, (QofSetterFunc)gnc_price_set_value },
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <qofinstance-p.h>
|
#include <qofinstance-p.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "gncEntry.h"
|
#include "gncEntry.h"
|
||||||
#include "gncEntryP.h"
|
#include "gncEntryP.h"
|
||||||
@ -50,8 +51,8 @@ struct _gncOrder
|
|||||||
char * printname;
|
char * printname;
|
||||||
GncOwner owner;
|
GncOwner owner;
|
||||||
GList * entries;
|
GList * entries;
|
||||||
Timespec opened;
|
time64 opened;
|
||||||
Timespec closed;
|
time64 closed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _gncOrderClass
|
struct _gncOrderClass
|
||||||
@ -101,6 +102,7 @@ G_DEFINE_TYPE(GncOrder, gnc_order, QOF_TYPE_INSTANCE);
|
|||||||
static void
|
static void
|
||||||
gnc_order_init(GncOrder* order)
|
gnc_order_init(GncOrder* order)
|
||||||
{
|
{
|
||||||
|
order->closed = INT64_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -177,10 +179,10 @@ gnc_order_set_property (GObject *object,
|
|||||||
gncOrderSetActive(order, g_value_get_boolean(value));
|
gncOrderSetActive(order, g_value_get_boolean(value));
|
||||||
break;
|
break;
|
||||||
case PROP_DATE_OPENED:
|
case PROP_DATE_OPENED:
|
||||||
gncOrderSetDateOpened(order, *(Timespec*)g_value_get_boxed(value));
|
gncOrderSetDateOpened(order, g_value_get_int64(value));
|
||||||
break;
|
break;
|
||||||
case PROP_DATE_CLOSED:
|
case PROP_DATE_CLOSED:
|
||||||
gncOrderSetDateClosed(order, *(Timespec*)g_value_get_boxed(value));
|
gncOrderSetDateClosed(order, g_value_get_int64(value));
|
||||||
break;
|
break;
|
||||||
case PROP_REFERENCE:
|
case PROP_REFERENCE:
|
||||||
gncOrderSetReference(order, g_value_get_string(value));
|
gncOrderSetReference(order, g_value_get_string(value));
|
||||||
@ -346,20 +348,20 @@ void gncOrderSetOwner (GncOrder *order, GncOwner *owner)
|
|||||||
gncOrderCommitEdit (order);
|
gncOrderCommitEdit (order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncOrderSetDateOpened (GncOrder *order, Timespec date)
|
void gncOrderSetDateOpened (GncOrder *order, time64 date)
|
||||||
{
|
{
|
||||||
if (!order) return;
|
if (!order) return;
|
||||||
if (timespec_equal (&order->opened, &date)) return;
|
if (order->opened == date) return;
|
||||||
gncOrderBeginEdit (order);
|
gncOrderBeginEdit (order);
|
||||||
order->opened = date;
|
order->opened = date;
|
||||||
mark_order (order);
|
mark_order (order);
|
||||||
gncOrderCommitEdit (order);
|
gncOrderCommitEdit (order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncOrderSetDateClosed (GncOrder *order, Timespec date)
|
void gncOrderSetDateClosed (GncOrder *order, time64 date)
|
||||||
{
|
{
|
||||||
if (!order) return;
|
if (!order) return;
|
||||||
if (timespec_equal (&order->closed, &date)) return;
|
if (order->closed == date) return;
|
||||||
gncOrderBeginEdit (order);
|
gncOrderBeginEdit (order);
|
||||||
order->closed = date;
|
order->closed = date;
|
||||||
mark_order (order);
|
mark_order (order);
|
||||||
@ -439,21 +441,15 @@ GncOwner * gncOrderGetOwner (GncOrder *order)
|
|||||||
return &order->owner;
|
return &order->owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timespec gncOrderGetDateOpened (const GncOrder *order)
|
time64 gncOrderGetDateOpened (const GncOrder *order)
|
||||||
{
|
{
|
||||||
Timespec ts;
|
if (!order) return INT64_MAX;
|
||||||
ts.tv_sec = 0;
|
|
||||||
ts.tv_nsec = 0;
|
|
||||||
if (!order) return ts;
|
|
||||||
return order->opened;
|
return order->opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timespec gncOrderGetDateClosed (const GncOrder *order)
|
time64 gncOrderGetDateClosed (const GncOrder *order)
|
||||||
{
|
{
|
||||||
Timespec ts;
|
if (!order) return INT64_MAX;
|
||||||
ts.tv_sec = 0;
|
|
||||||
ts.tv_nsec = 0;
|
|
||||||
if (!order) return ts;
|
|
||||||
return order->closed;
|
return order->closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +481,7 @@ GList * gncOrderGetEntries (GncOrder *order)
|
|||||||
gboolean gncOrderIsClosed (const GncOrder *order)
|
gboolean gncOrderIsClosed (const GncOrder *order)
|
||||||
{
|
{
|
||||||
if (!order) return FALSE;
|
if (!order) return FALSE;
|
||||||
if (order->closed.tv_sec || order->closed.tv_nsec) return TRUE;
|
if (order->closed != INT64_MAX) return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,11 +524,8 @@ int gncOrderCompare (const GncOrder *a, const GncOrder *b)
|
|||||||
compare = g_strcmp0 (a->id, b->id);
|
compare = g_strcmp0 (a->id, b->id);
|
||||||
if (compare) return compare;
|
if (compare) return compare;
|
||||||
|
|
||||||
compare = timespec_cmp (&(a->opened), &(b->opened));
|
if (a->opened != b->opened) return a->opened - b->opened;
|
||||||
if (compare) return compare;
|
if (a->closed != b->closed) return a->closed - b->closed;
|
||||||
|
|
||||||
compare = timespec_cmp (&(a->closed), &(b->closed));
|
|
||||||
if (compare) return compare;
|
|
||||||
|
|
||||||
return qof_instance_guid_compare(a, b);
|
return qof_instance_guid_compare(a, b);
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,8 @@ void gncOrderDestroy (GncOrder *order);
|
|||||||
|
|
||||||
void gncOrderSetID (GncOrder *order, const char *id);
|
void gncOrderSetID (GncOrder *order, const char *id);
|
||||||
void gncOrderSetOwner (GncOrder *order, GncOwner *owner);
|
void gncOrderSetOwner (GncOrder *order, GncOwner *owner);
|
||||||
void gncOrderSetDateOpened (GncOrder *order, Timespec date);
|
void gncOrderSetDateOpened (GncOrder *order, time64 date);
|
||||||
void gncOrderSetDateClosed (GncOrder *order, Timespec date);
|
void gncOrderSetDateClosed (GncOrder *order, time64 date);
|
||||||
void gncOrderSetNotes (GncOrder *order, const char *notes);
|
void gncOrderSetNotes (GncOrder *order, const char *notes);
|
||||||
void gncOrderSetReference (GncOrder *order, const char *reference);
|
void gncOrderSetReference (GncOrder *order, const char *reference);
|
||||||
void gncOrderSetActive (GncOrder *order, gboolean active);
|
void gncOrderSetActive (GncOrder *order, gboolean active);
|
||||||
@ -80,8 +80,8 @@ void gncOrderRemoveEntry (GncOrder *order, GncEntry *entry);
|
|||||||
|
|
||||||
const char * gncOrderGetID (const GncOrder *order);
|
const char * gncOrderGetID (const GncOrder *order);
|
||||||
GncOwner * gncOrderGetOwner (GncOrder *order);
|
GncOwner * gncOrderGetOwner (GncOrder *order);
|
||||||
Timespec gncOrderGetDateOpened (const GncOrder *order);
|
time64 gncOrderGetDateOpened (const GncOrder *order);
|
||||||
Timespec gncOrderGetDateClosed (const GncOrder *order);
|
time64 gncOrderGetDateClosed (const GncOrder *order);
|
||||||
const char * gncOrderGetNotes (const GncOrder *order);
|
const char * gncOrderGetNotes (const GncOrder *order);
|
||||||
const char * gncOrderGetReference (const GncOrder *order);
|
const char * gncOrderGetReference (const GncOrder *order);
|
||||||
gboolean gncOrderGetActive (const GncOrder *order);
|
gboolean gncOrderGetActive (const GncOrder *order);
|
||||||
|
@ -1829,7 +1829,7 @@ qof_query_printValueForParam (QofQueryPredData *pd, GString * gs)
|
|||||||
query_date_t pdata = (query_date_t) pd;
|
query_date_t pdata = (query_date_t) pd;
|
||||||
g_string_append_printf (gs, " Match type %s",
|
g_string_append_printf (gs, " Match type %s",
|
||||||
qof_query_printDateMatch (pdata->options));
|
qof_query_printDateMatch (pdata->options));
|
||||||
g_string_append_printf (gs, " query_date: %s", gnc_print_date (pdata->date));
|
g_string_append_printf (gs, " query_date: %s", gnc_print_date ({pdata->date, 0}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!g_strcmp0 (pd->type_name, QOF_TYPE_CHAR))
|
if (!g_strcmp0 (pd->type_name, QOF_TYPE_CHAR))
|
||||||
|
@ -75,7 +75,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
QofQueryPredData pd;
|
QofQueryPredData pd;
|
||||||
QofDateMatch options;
|
QofDateMatch options;
|
||||||
Timespec date;
|
time64 date;
|
||||||
} query_date_def, *query_date_t;
|
} query_date_def, *query_date_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -57,7 +57,7 @@ static QueryPredDataFree qof_query_predicate_free (QofType type);
|
|||||||
typedef const char * (*query_string_getter) (gpointer, QofParam *);
|
typedef const char * (*query_string_getter) (gpointer, QofParam *);
|
||||||
static const char * query_string_type = QOF_TYPE_STRING;
|
static const char * query_string_type = QOF_TYPE_STRING;
|
||||||
|
|
||||||
typedef Timespec (*query_date_getter) (gpointer, QofParam *);
|
typedef time64 (*query_date_getter) (gpointer, QofParam *);
|
||||||
static const char * query_date_type = QOF_TYPE_DATE;
|
static const char * query_date_type = QOF_TYPE_DATE;
|
||||||
|
|
||||||
typedef gnc_numeric (*query_numeric_getter) (gpointer, QofParam *);
|
typedef gnc_numeric (*query_numeric_getter) (gpointer, QofParam *);
|
||||||
@ -326,23 +326,18 @@ string_to_string (gpointer object, QofParam *getter)
|
|||||||
/* QOF_TYPE_DATE =================================================== */
|
/* QOF_TYPE_DATE =================================================== */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
date_compare (Timespec ta, Timespec tb, QofDateMatch options)
|
date_compare (time64 ta, time64 tb, QofDateMatch options)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (options == QOF_DATE_MATCH_DAY)
|
if (options == QOF_DATE_MATCH_DAY)
|
||||||
{
|
{
|
||||||
ta = timespecCanonicalDayTime (ta);
|
ta = time64CanonicalDayTime (ta);
|
||||||
tb = timespecCanonicalDayTime (tb);
|
tb = time64CanonicalDayTime (tb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ta.tv_sec < tb.tv_sec)
|
if (ta < tb)
|
||||||
return -1;
|
return -1;
|
||||||
if (ta.tv_sec > tb.tv_sec)
|
if (ta > tb)
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (ta.tv_nsec < tb.tv_nsec)
|
|
||||||
return -1;
|
|
||||||
if (ta.tv_nsec > tb.tv_nsec)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -353,7 +348,7 @@ date_match_predicate (gpointer object, QofParam *getter,
|
|||||||
QofQueryPredData *pd)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
query_date_t pdata = (query_date_t)pd;
|
query_date_t pdata = (query_date_t)pd;
|
||||||
Timespec objtime;
|
time64 objtime;
|
||||||
int compare;
|
int compare;
|
||||||
|
|
||||||
VERIFY_PREDICATE (query_date_type);
|
VERIFY_PREDICATE (query_date_type);
|
||||||
@ -384,7 +379,7 @@ date_match_predicate (gpointer object, QofParam *getter,
|
|||||||
static int
|
static int
|
||||||
date_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
date_compare_func (gpointer a, gpointer b, gint options, QofParam *getter)
|
||||||
{
|
{
|
||||||
Timespec ta, tb;
|
time64 ta, tb;
|
||||||
|
|
||||||
g_return_val_if_fail (a && b && getter && getter->param_getfcn, COMPARE_ERROR);
|
g_return_val_if_fail (a && b && getter && getter->param_getfcn, COMPARE_ERROR);
|
||||||
|
|
||||||
@ -421,12 +416,12 @@ date_predicate_equal (const QofQueryPredData *p1, const QofQueryPredData *p2)
|
|||||||
const query_date_t pd2 = (const query_date_t) p2;
|
const query_date_t pd2 = (const query_date_t) p2;
|
||||||
|
|
||||||
if (pd1->options != pd2->options) return FALSE;
|
if (pd1->options != pd2->options) return FALSE;
|
||||||
return timespec_equal (&(pd1->date), &(pd2->date));
|
return (pd1->date == pd2->date);
|
||||||
}
|
}
|
||||||
|
|
||||||
QofQueryPredData *
|
QofQueryPredData *
|
||||||
qof_query_date_predicate (QofQueryCompare how,
|
qof_query_date_predicate (QofQueryCompare how,
|
||||||
QofDateMatch options, Timespec date)
|
QofDateMatch options, time64 date)
|
||||||
{
|
{
|
||||||
query_date_t pdata;
|
query_date_t pdata;
|
||||||
|
|
||||||
@ -439,7 +434,7 @@ qof_query_date_predicate (QofQueryCompare how,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
qof_query_date_predicate_get_date (const QofQueryPredData *pd, Timespec *date)
|
qof_query_date_predicate_get_date (const QofQueryPredData *pd, time64 *date)
|
||||||
{
|
{
|
||||||
const query_date_t pdata = (const query_date_t)pd;
|
const query_date_t pdata = (const query_date_t)pd;
|
||||||
|
|
||||||
@ -452,10 +447,10 @@ qof_query_date_predicate_get_date (const QofQueryPredData *pd, Timespec *date)
|
|||||||
static char *
|
static char *
|
||||||
date_to_string (gpointer object, QofParam *getter)
|
date_to_string (gpointer object, QofParam *getter)
|
||||||
{
|
{
|
||||||
Timespec ts = ((query_date_getter)getter->param_getfcn)(object, getter);
|
time64 tt = ((query_date_getter)getter->param_getfcn)(object, getter);
|
||||||
|
|
||||||
if (ts.tv_sec != INT64_MAX)
|
if (tt != INT64_MAX)
|
||||||
return g_strdup (gnc_print_date (ts));
|
return g_strdup (gnc_print_date ({tt, 0}));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ QofQueryPredData *qof_query_string_predicate (QofQueryCompare how,
|
|||||||
|
|
||||||
QofQueryPredData *qof_query_date_predicate (QofQueryCompare how,
|
QofQueryPredData *qof_query_date_predicate (QofQueryCompare how,
|
||||||
QofDateMatch options,
|
QofDateMatch options,
|
||||||
Timespec date);
|
time64 date);
|
||||||
|
|
||||||
QofQueryPredData *qof_query_numeric_predicate (QofQueryCompare how,
|
QofQueryPredData *qof_query_numeric_predicate (QofQueryCompare how,
|
||||||
QofNumericMatch options,
|
QofNumericMatch options,
|
||||||
@ -183,7 +183,7 @@ QofQueryPredData *qof_query_core_predicate_copy (const QofQueryPredData *pdata);
|
|||||||
void qof_query_core_predicate_free (QofQueryPredData *pdata);
|
void qof_query_core_predicate_free (QofQueryPredData *pdata);
|
||||||
|
|
||||||
/** Retrieve a predicate. */
|
/** Retrieve a predicate. */
|
||||||
gboolean qof_query_date_predicate_get_date (const QofQueryPredData *pd, Timespec *date);
|
gboolean qof_query_date_predicate_get_date (const QofQueryPredData *pd, time64 *date);
|
||||||
/** Return a printable string for a core data object. Caller needs
|
/** Return a printable string for a core data object. Caller needs
|
||||||
* to g_free() the returned string.
|
* to g_free() the returned string.
|
||||||
*/
|
*/
|
||||||
|
@ -1738,8 +1738,8 @@ get_random_query(void)
|
|||||||
{
|
{
|
||||||
gint pr_type;
|
gint pr_type;
|
||||||
KvpValue *value;
|
KvpValue *value;
|
||||||
Timespec *start;
|
time64 start;
|
||||||
Timespec *end;
|
time64 end;
|
||||||
GList *guids;
|
GList *guids;
|
||||||
GSList *path;
|
GSList *path;
|
||||||
char *string;
|
char *string;
|
||||||
@ -1791,16 +1791,14 @@ get_random_query(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: /* PR_DATE */
|
case 5: /* PR_DATE */
|
||||||
start = get_random_timespec ();
|
start = get_random_time ();
|
||||||
end = get_random_timespec ();
|
end = get_random_time ();
|
||||||
xaccQueryAddDateMatchTS (q,
|
xaccQueryAddDateMatchTT (q,
|
||||||
get_random_boolean (),
|
get_random_boolean (),
|
||||||
*start,
|
start,
|
||||||
get_random_boolean (),
|
get_random_boolean (),
|
||||||
*end,
|
end,
|
||||||
get_random_queryop ());
|
get_random_queryop ());
|
||||||
g_free (start);
|
|
||||||
g_free (end);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: /* PR_DESC */
|
case 6: /* PR_DESC */
|
||||||
|
Loading…
Reference in New Issue
Block a user