Transaction getVoidTime uses time64.

This commit is contained in:
lmat 2017-12-23 13:06:59 -05:00 committed by Christopher Lam
parent 978ec61f98
commit 588fcb6ed2
3 changed files with 11 additions and 11 deletions

View File

@ -2754,19 +2754,19 @@ xaccTransGetVoidReason(const Transaction *trans)
return NULL; return NULL;
} }
Timespec time64
xaccTransGetVoidTime(const Transaction *tr) xaccTransGetVoidTime(const Transaction *tr)
{ {
GValue v = G_VALUE_INIT; GValue v = G_VALUE_INIT;
const char *s = NULL; const char *s = NULL;
Timespec void_time = {0, 0}; time64 void_time = 0;
g_return_val_if_fail(tr, void_time); g_return_val_if_fail(tr, void_time);
qof_instance_get_kvp (QOF_INSTANCE (tr), &v, 1, void_time_str); qof_instance_get_kvp (QOF_INSTANCE (tr), &v, 1, void_time_str);
if (G_VALUE_HOLDS_STRING (&v)) if (G_VALUE_HOLDS_STRING (&v))
s = g_value_get_string (&v); s = g_value_get_string (&v);
if (s) if (s)
return gnc_iso8601_to_timespec_gmt (s); return gnc_iso8601_to_timespec_gmt (s).tv_sec;
return void_time; return void_time;
} }

View File

@ -756,10 +756,10 @@ const char *xaccTransGetVoidReason(const Transaction *transaction);
* *
* @param tr The transaction in question. * @param tr The transaction in question.
* *
* @return A Timespec containing the time that this transaction was * @return A time64 containing the time that this transaction was
* voided. Returns a time of zero upon error. * voided. Returns a time of zero upon error.
*/ */
Timespec xaccTransGetVoidTime(const Transaction *tr); time64 xaccTransGetVoidTime(const Transaction *tr);
/** @} */ /** @} */
/** @name Transaction Parameter names /** @name Transaction Parameter names

View File

@ -58,7 +58,7 @@ run_test (void)
Transaction *transaction; Transaction *transaction;
gnc_numeric old_amt, new_amt, old_val, new_val; gnc_numeric old_amt, new_amt, old_val, new_val;
QofBook *book; QofBook *book;
Timespec ts; time64 time;
time64 now; time64 now;
const char *reason = "because I can"; const char *reason = "because I can";
@ -97,10 +97,10 @@ run_test (void)
xaccTransVoid(transaction, reason); xaccTransVoid(transaction, reason);
ts = xaccTransGetVoidTime (transaction); time = xaccTransGetVoidTime (transaction);
/* figure at most 2 seconds difference */ /* figure at most 2 seconds difference */
if ((ts.tv_sec < now) || ((ts.tv_sec - now) > 2)) if ((time < now) || ((time - now) > 2))
{ {
failure("bad void time"); failure("bad void time");
} }
@ -146,10 +146,10 @@ run_test (void)
*/ */
xaccTransUnvoid(transaction); xaccTransUnvoid(transaction);
ts = xaccTransGetVoidTime (transaction); time = xaccTransGetVoidTime (transaction);
/* figure at most 2 seconds difference */ /* figure at most 2 seconds difference */
if ((ts.tv_sec != 0) || (ts.tv_sec != 0)) if ((time != 0))
{ {
failure("void time not zero after restore"); failure("void time not zero after restore");
} }
@ -193,7 +193,7 @@ run_test (void)
xaccTransSetReadOnly (transaction, "Read-only void test"); xaccTransSetReadOnly (transaction, "Read-only void test");
xaccTransVoid(transaction, reason); xaccTransVoid(transaction, reason);
ts = xaccTransGetVoidTime (transaction); time = xaccTransGetVoidTime (transaction);
if (xaccTransGetVoidStatus(transaction)) if (xaccTransGetVoidStatus(transaction))
{ {