gncInvoice uses time64

This commit is contained in:
lmat
2017-12-29 16:07:08 -05:00
committed by Christopher Lam
parent 598cb6d861
commit 9a86dd222b
11 changed files with 89 additions and 129 deletions

View File

@@ -81,17 +81,17 @@ maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
}
static void
maybe_add_timespec (xmlNodePtr ptr, const char* tag, Timespec ts)
maybe_add_time64 (xmlNodePtr ptr, const char* tag, time64 time)
{
if (ts.tv_sec)
xmlAddChild (ptr, time64_to_dom_tree (tag, ts.tv_sec));
if (time)
xmlAddChild (ptr, time64_to_dom_tree (tag, time));
}
static xmlNodePtr
invoice_dom_tree_create (GncInvoice* invoice)
{
xmlNodePtr ret;
Timespec ts;
time64 time;
Transaction* txn;
GNCLot* lot;
Account* acc;
@@ -111,11 +111,10 @@ invoice_dom_tree_create (GncInvoice* invoice)
xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_owner_string,
gncInvoiceGetOwner (invoice)));
ts = gncInvoiceGetDateOpened (invoice);
xmlAddChild (ret, time64_to_dom_tree (invoice_opened_string, ts.tv_sec));
time = gncInvoiceGetDateOpened (invoice);
xmlAddChild (ret, time64_to_dom_tree (invoice_opened_string, time));
maybe_add_timespec (ret, invoice_posted_string,
gncInvoiceGetDatePosted (invoice));
maybe_add_time64 (ret, invoice_posted_string, gncInvoiceGetDatePosted (invoice));
term = gncInvoiceGetTerms (invoice);
if (term)
@@ -185,14 +184,12 @@ set_string (xmlNodePtr node, GncInvoice* invoice,
}
static inline gboolean
set_timespec (xmlNodePtr node, GncInvoice* invoice,
void (*func) (GncInvoice* invoice, Timespec ts))
set_time64 (xmlNodePtr node, GncInvoice* invoice,
void (*func) (GncInvoice* invoice, time64 time))
{
time64 time = dom_tree_to_time64 (node);
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
Timespec ts = {time, 0};
func (invoice, ts);
func (invoice, time);
return TRUE;
}
@@ -248,16 +245,14 @@ static gboolean
invoice_opened_handler (xmlNodePtr node, gpointer invoice_pdata)
{
struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
return set_timespec (node, pdata->invoice, gncInvoiceSetDateOpened);
return set_time64 (node, pdata->invoice, gncInvoiceSetDateOpened);
}
static gboolean
invoice_posted_handler (xmlNodePtr node, gpointer invoice_pdata)
{
struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
return set_timespec (node, pdata->invoice, gncInvoiceSetDatePosted);
return set_time64 (node, pdata->invoice, gncInvoiceSetDatePosted);
}
static gboolean