r22621 - gnucash/trunk/src/engine - Convert all time_t to time64: engine

John Ralls jralls at code.gnucash.org
Sat Dec 1 17:44:53 EST 2012


Author: jralls
Date: 2012-12-01 17:44:53 -0500 (Sat, 01 Dec 2012)
New Revision: 22621
Trac: http://svn.gnucash.org/trac/changeset/22621

Modified:
   gnucash/trunk/src/engine/Account.c
   gnucash/trunk/src/engine/Account.h
   gnucash/trunk/src/engine/Query.c
   gnucash/trunk/src/engine/Query.h
   gnucash/trunk/src/engine/Recurrence.c
   gnucash/trunk/src/engine/Recurrence.h
   gnucash/trunk/src/engine/SchedXaction.c
   gnucash/trunk/src/engine/Split.c
   gnucash/trunk/src/engine/Split.h
   gnucash/trunk/src/engine/TransLog.c
   gnucash/trunk/src/engine/Transaction.c
   gnucash/trunk/src/engine/Transaction.h
   gnucash/trunk/src/engine/cap-gains.c
   gnucash/trunk/src/engine/gnc-budget.c
   gnucash/trunk/src/engine/gncInvoice.c
   gnucash/trunk/src/engine/gncOwner.c
   gnucash/trunk/src/engine/gncTaxTable.c
   gnucash/trunk/src/engine/test/test-transaction-voiding.c
   gnucash/trunk/src/engine/test/utest-Account.c
   gnucash/trunk/src/engine/test/utest-Budget.c
Log:
Convert all time_t to time64: engine

Modified: gnucash/trunk/src/engine/Account.c
===================================================================
--- gnucash/trunk/src/engine/Account.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Account.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -3038,14 +3038,14 @@
 {
     AccountPrivate *priv;
     GList *node;
-    time_t today;
+    time64 today;
     gnc_numeric lowest = gnc_numeric_zero ();
     int seen_a_transaction = 0;
 
     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), gnc_numeric_zero());
 
     priv = GET_PRIVATE(acc);
-    today = gnc_timet_get_today_end();
+    today = gnc_time64_get_today_end();
     for (node = g_list_last(priv->splits); node; node = node->prev)
     {
         Split *split = node->data;
@@ -3072,7 +3072,7 @@
 \********************************************************************/
 
 gnc_numeric
-xaccAccountGetBalanceAsOfDate (Account *acc, time_t date)
+xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
 {
     /* Ideally this could use xaccAccountForEachSplit, but
      * it doesn't exist yet and I'm uncertain of exactly how
@@ -3096,11 +3096,11 @@
 
     /* 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 time_t.
+     * 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 time_t, and it's hard to
+     * 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
@@ -3156,12 +3156,12 @@
 {
     AccountPrivate *priv;
     GList *node;
-    time_t today;
+    time64 today;
 
     g_return_val_if_fail(GNC_IS_ACCOUNT(acc), gnc_numeric_zero());
 
     priv = GET_PRIVATE(acc);
-    today = gnc_timet_get_today_end();
+    today = gnc_time64_get_today_end();
     for (node = g_list_last(priv->splits); node; node = node->prev)
     {
         Split *split = node->data;
@@ -3214,7 +3214,7 @@
         gnc_numeric balance,
         gnc_commodity *balance_currency,
         gnc_commodity *new_currency,
-        time_t date)
+        time64 date)
 {
     QofBook *book;
     GNCPriceDB *pdb;
@@ -3262,7 +3262,7 @@
 }
 
 static gnc_numeric
-xaccAccountGetXxxBalanceAsOfDateInCurrency(Account *acc, time_t date,
+xaccAccountGetXxxBalanceAsOfDateInCurrency(Account *acc, time64 date,
         xaccGetBalanceAsOfDateFn fn,
         const gnc_commodity *report_commodity)
 {
@@ -3286,7 +3286,7 @@
     gnc_numeric balance;
     xaccGetBalanceFn fn;
     xaccGetBalanceAsOfDateFn asOfDateFn;
-    time_t date;
+    time64 date;
 } CurrencyBalance;
 
 
@@ -3375,7 +3375,7 @@
 
 static gnc_numeric
 xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive (
-    Account *acc, time_t date, xaccGetBalanceAsOfDateFn fn,
+    Account *acc, time64 date, xaccGetBalanceAsOfDateFn fn,
     gnc_commodity *report_commodity, gboolean include_children)
 {
     gnc_numeric balance;
@@ -3466,7 +3466,7 @@
 
 gnc_numeric
 xaccAccountGetBalanceAsOfDateInCurrency(
-    Account *acc, time_t date, gnc_commodity *report_commodity,
+    Account *acc, time64 date, gnc_commodity *report_commodity,
     gboolean include_children)
 {
     return xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive (
@@ -3475,7 +3475,8 @@
 }
 
 gnc_numeric
-xaccAccountGetBalanceChangeForPeriod (Account *acc, time_t t1, time_t t2, gboolean recurse)
+xaccAccountGetBalanceChangeForPeriod (Account *acc, time64 t1, time64 t2,
+				      gboolean recurse)
 {
     gnc_numeric b1, b2;
 
@@ -3992,7 +3993,7 @@
 \********************************************************************/
 
 gboolean
-xaccAccountGetReconcileLastDate (const Account *acc, time_t *last_date)
+xaccAccountGetReconcileLastDate (const Account *acc, time64 *last_date)
 {
     KvpValue *v;
 
@@ -4013,7 +4014,7 @@
 \********************************************************************/
 
 void
-xaccAccountSetReconcileLastDate (Account *acc, time_t last_date)
+xaccAccountSetReconcileLastDate (Account *acc, time64 last_date)
 {
     if (!acc) return;
 
@@ -4076,7 +4077,7 @@
 \********************************************************************/
 
 gboolean
-xaccAccountGetReconcilePostponeDate (const Account *acc, time_t *postpone_date)
+xaccAccountGetReconcilePostponeDate (const Account *acc, time64 *postpone_date)
 {
     KvpValue *v;
 
@@ -4096,7 +4097,7 @@
 \********************************************************************/
 
 void
-xaccAccountSetReconcilePostponeDate (Account *acc, time_t postpone_date)
+xaccAccountSetReconcilePostponeDate (Account *acc, time64 postpone_date)
 {
     if (!acc) return;
 

Modified: gnucash/trunk/src/engine/Account.h
===================================================================
--- gnucash/trunk/src/engine/Account.h	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Account.h	2012-12-01 22:44:53 UTC (rev 22621)
@@ -55,7 +55,7 @@
     gboolean include_children);
 
 typedef gnc_numeric (*xaccGetBalanceAsOfDateFn) (
-    Account *account, time_t date);
+    Account *account, time64 date);
 
 typedef void (*AccountCb)(Account *a, gpointer data);
 typedef gpointer (*AccountCb2)(Account *a, gpointer data);
@@ -524,7 +524,7 @@
 gnc_numeric xaccAccountGetProjectedMinimumBalance (const Account *account);
 /** Get the balance of the account as of the date specified */
 gnc_numeric xaccAccountGetBalanceAsOfDate (Account *account,
-        time_t date);
+        time64 date);
 
 /* These two functions convert a given balance from one commodity to
    another.  The account argument is only used to get the Book, and
@@ -543,7 +543,7 @@
 gnc_numeric xaccAccountConvertBalanceToCurrencyAsOfDate(
     const Account *account, /* for book */
     gnc_numeric balance, gnc_commodity *balance_currency,
-    gnc_commodity *new_currency, time_t date);
+    gnc_commodity *new_currency, time64 date);
 
 /* These functions get some type of balance in the desired commodity.
    'report_commodity' may be NULL to use the account's commodity. */
@@ -566,11 +566,11 @@
 /* This function gets the balance as of the given date in the desired
    commodity. */
 gnc_numeric xaccAccountGetBalanceAsOfDateInCurrency(
-    Account *account, time_t date, gnc_commodity *report_commodity,
+    Account *account, time64 date, gnc_commodity *report_commodity,
     gboolean include_children);
 
 gnc_numeric xaccAccountGetBalanceChangeForPeriod (
-    Account *acc, time_t date1, time_t date2, gboolean recurse);
+    Account *acc, time64 date1, time64 date2, gboolean recurse);
 
 /** @} */
 
@@ -1054,9 +1054,9 @@
 */
 /** DOCUMENT ME! */
 gboolean xaccAccountGetReconcileLastDate (const Account *account,
-        time_t *last_date);
+        time64 *last_date);
 /** DOCUMENT ME! */
-void xaccAccountSetReconcileLastDate (Account *account, time_t last_date);
+void xaccAccountSetReconcileLastDate (Account *account, time64 last_date);
 
 /** DOCUMENT ME! */
 gboolean xaccAccountGetReconcileLastInterval (const Account *account,
@@ -1066,10 +1066,10 @@
         int months, int days);
 /** DOCUMENT ME! */
 gboolean xaccAccountGetReconcilePostponeDate (const Account *account,
-        time_t *postpone_date);
+        time64 *postpone_date);
 /** DOCUMENT ME! */
 void xaccAccountSetReconcilePostponeDate (Account *account,
-        time_t postpone_date);
+        time64 postpone_date);
 
 /** DOCUMENT ME! */
 gboolean xaccAccountGetReconcilePostponeBalance (const Account *account,

Modified: gnucash/trunk/src/engine/Query.c
===================================================================
--- gnucash/trunk/src/engine/Query.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Query.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -30,9 +30,6 @@
 #include <sys/types.h>
 
 #include <regex.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
@@ -476,18 +473,18 @@
 void
 xaccQueryAddDateMatchTT(QofQuery * q,
                         gboolean use_start,
-                        time_t stt,
+                        time64 stt,
                         gboolean use_end,
-                        time_t ett,
+                        time64 ett,
                         QofQueryOp op)
 {
     Timespec   sts;
     Timespec   ets;
 
-    sts.tv_sec  = (long long)stt;
+    sts.tv_sec  = stt;
     sts.tv_nsec = 0;
 
-    ets.tv_sec  = (long long)ett;
+    ets.tv_sec  = ett;
     ets.tv_nsec = 0;
 
     /* gcc -O3 will auto-inline this function, avoiding a call overhead */
@@ -498,8 +495,8 @@
 
 void
 xaccQueryGetDateMatchTT (QofQuery * q,
-                         time_t * stt,
-                         time_t * ett)
+                         time64 * stt,
+                         time64 * ett)
 {
     Timespec   sts;
     Timespec   ets;
@@ -594,26 +591,26 @@
  *  xaccQueryGetEarliestDateFound
  *******************************************************************/
 
-time_t
+time64
 xaccQueryGetEarliestDateFound(QofQuery * q)
 {
     GList * spl;
     Split * sp;
-    time_t earliest;
+    time64 earliest;
 
     if (!q) return 0;
     spl = qof_query_last_run (q);
     if (!spl) return 0;
 
-    /* Safe until 2038 on archs where time_t is 32bit */
+    /* Safe until 2038 on archs where time64 is 32bit */
     sp = spl->data;
-    earliest = (time_t) sp->parent->date_posted.tv_sec;
+    earliest = sp->parent->date_posted.tv_sec;
     for (; spl; spl = spl->next)
     {
         sp = spl->data;
         if (sp->parent->date_posted.tv_sec < earliest)
         {
-            earliest = (time_t) sp->parent->date_posted.tv_sec;
+            earliest = sp->parent->date_posted.tv_sec;
         }
     }
     return earliest;
@@ -623,12 +620,12 @@
  *  xaccQueryGetLatestDateFound
  *******************************************************************/
 
-time_t
+time64
 xaccQueryGetLatestDateFound(QofQuery * q)
 {
     Split  * sp;
     GList  * spl;
-    time_t latest = 0;
+    time64 latest = 0;
 
     if (!q) return 0;
     spl = qof_query_last_run (q);
@@ -639,7 +636,7 @@
         sp = spl->data;
         if (sp->parent->date_posted.tv_sec > latest)
         {
-            latest = (time_t) sp->parent->date_posted.tv_sec;
+            latest = sp->parent->date_posted.tv_sec;
         }
     }
     return latest;

Modified: gnucash/trunk/src/engine/Query.h
===================================================================
--- gnucash/trunk/src/engine/Query.h	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Query.h	2012-12-01 22:44:53 UTC (rev 22621)
@@ -156,15 +156,15 @@
                              gboolean use_end, Timespec ets,
                              QofQueryOp op);
 void xaccQueryAddDateMatchTT(QofQuery * q,
-                             gboolean use_start, time_t stt,
-                             gboolean use_end, time_t ett,
+                             gboolean use_start, time64 stt,
+                             gboolean use_end, time64 ett,
                              QofQueryOp op);
 void xaccQueryGetDateMatchTS (QofQuery * q,
                               Timespec * sts,
                               Timespec * ets);
 void xaccQueryGetDateMatchTT (QofQuery * q,
-                              time_t * stt,
-                              time_t * ett);
+                              time64 * stt,
+                              time64 * ett);
 
 typedef enum
 {
@@ -189,7 +189,7 @@
 /*******************************************************************
  *  compatibility interface with old QofQuery API
  *******************************************************************/
-time_t xaccQueryGetEarliestDateFound(QofQuery * q);
-time_t xaccQueryGetLatestDateFound(QofQuery * q);
+time64 xaccQueryGetEarliestDateFound(QofQuery * q);
+time64 xaccQueryGetLatestDateFound(QofQuery * q);
 
 #endif

Modified: gnucash/trunk/src/engine/Recurrence.c
===================================================================
--- gnucash/trunk/src/engine/Recurrence.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Recurrence.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -87,7 +87,7 @@
     }
     else
     {
-        g_date_set_time_t(&r->start, time(NULL));
+        gnc_gdate_set_today (&r->start);
     }
 
     /* Some of the unusual period types also specify phase.  For those
@@ -377,7 +377,7 @@
     }
 }
 
-time_t
+time64
 recurrenceGetPeriodTime(const Recurrence *r, guint period_num, gboolean end)
 {
     GDate date;
@@ -385,18 +385,18 @@
     if (end)
     {
         g_date_subtract_days(&date, 1);
-        return gnc_timet_get_day_end_gdate(&date);
+        return gnc_time64_get_day_end_gdate(&date);
     }
     else
     {
-        return gnc_timet_get_day_start_gdate(&date);
+        return gnc_time64_get_day_start_gdate(&date);
     }
 }
 
 gnc_numeric
 recurrenceGetAccountPeriodValue(const Recurrence *r, Account *acc, guint n)
 {
-    time_t t1, t2;
+    time64 t1, t2;
 
     // FIXME: maybe zero is not best error return val.
     g_return_val_if_fail(r && acc, gnc_numeric_zero());

Modified: gnucash/trunk/src/engine/Recurrence.h
===================================================================
--- gnucash/trunk/src/engine/Recurrence.h	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Recurrence.h	2012-12-01 22:44:53 UTC (rev 22621)
@@ -135,7 +135,7 @@
 
 /* Get a time coresponding to the beginning (or end if 'end' is true)
    of the nth instance of the recurrence. Also zero-based. */
-time_t recurrenceGetPeriodTime(const Recurrence *r, guint n, gboolean end);
+time64 recurrenceGetPeriodTime(const Recurrence *r, guint n, gboolean end);
 
 /**
  * @return the amount that an Account's value changed between the beginning

Modified: gnucash/trunk/src/engine/SchedXaction.c
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/SchedXaction.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -1111,7 +1111,7 @@
         xaccTransSetDescription(new_trans,
                                 gnc_ttinfo_get_description(tti));
 
-        xaccTransSetDatePostedSecs(new_trans, time(NULL));
+        xaccTransSetDatePostedSecs(new_trans, gnc_time (NULL));
 
         xaccTransSetNum(new_trans,
                         gnc_ttinfo_get_num(tti));

Modified: gnucash/trunk/src/engine/Split.c
===================================================================
--- gnucash/trunk/src/engine/Split.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Split.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -1576,7 +1576,7 @@
 }
 
 void
-xaccSplitSetDateReconciledSecs (Split *split, time_t secs)
+xaccSplitSetDateReconciledSecs (Split *split, time64 secs)
 {
     if (!split) return;
     xaccTransBeginEdit (split->parent);

Modified: gnucash/trunk/src/engine/Split.h
===================================================================
--- gnucash/trunk/src/engine/Split.h	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Split.h	2012-12-01 22:44:53 UTC (rev 22621)
@@ -179,8 +179,8 @@
 char          xaccSplitGetReconcile (const Split *split);
 
 /** Set the date on which this split was reconciled by specifying the
- * time as time_t. */
-void          xaccSplitSetDateReconciledSecs (Split *split, time_t time);
+ * 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);

Modified: gnucash/trunk/src/engine/TransLog.c
===================================================================
--- gnucash/trunk/src/engine/TransLog.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/TransLog.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -224,13 +224,13 @@
     if (!gen_logs) return;
     if (!trans_log) return;
 
-    timespecFromTime_t(&ts, time(NULL));
+    timespecFromTime64(&ts, gnc_time (NULL));
     gnc_timespec_to_iso8601_buff (ts, dnow);
 
-    timespecFromTime_t(&ts, trans->date_entered.tv_sec);
+    timespecFromTime64(&ts, trans->date_entered.tv_sec);
     gnc_timespec_to_iso8601_buff (ts, dent);
 
-    timespecFromTime_t(&ts, trans->date_posted.tv_sec);
+    timespecFromTime64(&ts, trans->date_posted.tv_sec);
     gnc_timespec_to_iso8601_buff (ts, dpost);
 
     guid_to_string_buff (xaccTransGetGUID(trans), trans_guid_str);
@@ -255,7 +255,7 @@
             acc_guid_str[0] = '\0';
         }
 
-        timespecFromTime_t(&ts, split->date_reconciled.tv_sec);
+        timespecFromTime64(&ts, split->date_reconciled.tv_sec);
         gnc_timespec_to_iso8601_buff (ts, drecn);
 
         guid_to_string_buff (xaccSplitGetGUID(split), split_guid_str);

Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Transaction.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -57,6 +57,7 @@
 #include "gnc-engine.h"
 #include "gnc-lot.h"
 #include "gnc-event.h"
+#include <gnc-gdate-utils.h>
 
 #include "qofbackend-p.h"
 
@@ -1632,8 +1633,8 @@
     xaccTransBeginEdit(trans);
 
     {
-        time_t secs = (time_t) val.tv_sec;
-        gchar *tstr = ctime(&secs);
+        time64 secs = (time64) val.tv_sec;
+        gchar *tstr = gnc_ctime (&secs);
         PINFO ("addr=%p set date to %" G_GUINT64_FORMAT ".%09ld %s",
                trans, val.tv_sec, val.tv_nsec, tstr ? tstr : "(null)");
     }
@@ -1659,7 +1660,7 @@
 }
 
 void
-xaccTransSetDatePostedSecs (Transaction *trans, time_t secs)
+xaccTransSetDatePostedSecs (Transaction *trans, time64 secs)
 {
     Timespec ts = {secs, 0};
     if (!trans) return;
@@ -1690,7 +1691,7 @@
 }
 
 void
-xaccTransSetDateEnteredSecs (Transaction *trans, time_t secs)
+xaccTransSetDateEnteredSecs (Transaction *trans, time64 secs)
 {
     Timespec ts = {secs, 0};
     if (!trans) return;
@@ -1935,7 +1936,7 @@
 /********************************************************************\
 \********************************************************************/
 
-time_t
+time64
 xaccTransGetDate (const Transaction *trans)
 {
     return trans ? trans->date_posted.tv_sec : 0;
@@ -2081,7 +2082,7 @@
 
     trans_date = xaccTransGetDatePostedGDate (trans);
 
-    g_date_set_time_t (&date_now, time(NULL));
+    gnc_gdate_set_time64 (&date_now, gnc_time (NULL));
 
     if (g_date_compare (&trans_date, &date_now) > 0)
         result = TRUE;
@@ -2203,7 +2204,7 @@
     kvp_frame_set_string(frame, trans_notes_str, _("Voided transaction"));
     kvp_frame_set_string(frame, void_reason_str, reason);
 
-    now.tv_sec = time(NULL);
+    now.tv_sec = gnc_time (NULL);
     now.tv_nsec = 0;
     gnc_timespec_to_iso8601_buff(now, iso8601_str);
     kvp_frame_set_string(frame, void_time_str, iso8601_str);

Modified: gnucash/trunk/src/engine/Transaction.h
===================================================================
--- gnucash/trunk/src/engine/Transaction.h	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/Transaction.h	2012-12-01 22:44:53 UTC (rev 22621)
@@ -487,10 +487,10 @@
 void xaccTransSetDatePostedGDate (Transaction *trans, GDate date);
 
 /** The xaccTransSetDatePostedSecs() method will modify the <i>posted</i>
-    date of the transaction, specified by a time_t (see ctime(3)). The
+    date of the transaction, specified by a time64 (see ctime(3)). The
     posted date is the date when this transaction was posted at the
     bank. */
-void          xaccTransSetDatePostedSecs (Transaction *trans, time_t time);
+void          xaccTransSetDatePostedSecs (Transaction *trans, time64 time);
 
 /**  The xaccTransSetDatePostedTS() method does the same thing as
      xaccTransSetDatePostedSecs(), but takes a struct timespec64. */
@@ -499,7 +499,7 @@
 
 /** Modify the date of when the transaction was entered. The entered
  * date is the date when the register entry was made. */
-void          xaccTransSetDateEnteredSecs (Transaction *trans, time_t time);
+void          xaccTransSetDateEnteredSecs (Transaction *trans, time64 time);
 /** Modify the date of when the transaction was entered. The entered
  * date is the date when the register entry was made. */
 void          xaccTransSetDateEnteredTS (Transaction *trans,
@@ -512,7 +512,7 @@
     the date when this transaction was posted at the bank. (Although
     having different function names, GetDate and GetDatePosted refer
     to the same single date.)*/
-time_t        xaccTransGetDate (const Transaction *trans);
+time64        xaccTransGetDate (const Transaction *trans);
 /** Retrieve the posted date of the transaction. The posted date is
     the date when this transaction was posted at the bank. (Although
     having different function names, GetDate and GetDatePosted refer

Modified: gnucash/trunk/src/engine/cap-gains.c
===================================================================
--- gnucash/trunk/src/engine/cap-gains.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/cap-gains.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -464,7 +464,7 @@
     /* If we are here, then (cmp == +1 iff (amt > baln)) and we need
      * to split up the split into pieces. Do it. */
     {
-        time_t now = time(0);
+        time64 now = gnc_time (NULL);
         Split * new_split;
         gnc_numeric amt_a, amt_b, amt_tot;
         gnc_numeric val_a, val_b, val_tot;
@@ -1015,7 +1015,7 @@
             /* Common to both */
             ts = xaccTransRetDatePostedTS (split->parent);
             xaccTransSetDatePostedTS (trans, &ts);
-            xaccTransSetDateEnteredSecs (trans, time(0));
+            xaccTransSetDateEnteredSecs (trans, gnc_time (NULL));
 
             xaccSplitSetAmount (lot_split, zero);
             xaccSplitSetValue (lot_split, value);

Modified: gnucash/trunk/src/engine/gnc-budget.c
===================================================================
--- gnucash/trunk/src/engine/gnc-budget.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/gnc-budget.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -94,7 +94,7 @@
     priv->description = CACHE_INSERT("");
 
     priv->num_periods = 12;
-    g_date_set_time_t(&date, time(NULL));
+    gnc_gdate_set_today (&date);
     g_date_subtract_days(&date, g_date_get_day(&date) - 1);
     recurrenceSet(&priv->recurrence, 1, PERIOD_MONTH, &date, WEEKEND_ADJ_NONE);
 }
@@ -571,8 +571,9 @@
 gnc_budget_get_period_start_date(const GncBudget *budget, guint period_num)
 {
     Timespec ts;
-    timespecFromTime_t(
-        &ts,  recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, FALSE));
+    timespecFromTime64(
+        &ts, recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence,
+				     period_num, FALSE));
     return ts;
 }
 
@@ -580,7 +581,7 @@
 gnc_budget_get_period_end_date(const GncBudget *budget, guint period_num)
 {
     Timespec ts;
-    timespecFromTime_t(
+    timespecFromTime64(
         &ts,  recurrenceGetPeriodTime(&GET_PRIVATE(budget)->recurrence, period_num, TRUE));
     return ts;
 }

Modified: gnucash/trunk/src/engine/gncInvoice.c
===================================================================
--- gnucash/trunk/src/engine/gncInvoice.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/gncInvoice.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -1304,7 +1304,7 @@
     xaccTransSetCurrency (txn, invoice->currency);
 
     /* Entered and Posted at date */
-    xaccTransSetDateEnteredSecs (txn, time(NULL));
+    xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
     if (post_date)
     {
         xaccTransSetDatePostedTS (txn, post_date);

Modified: gnucash/trunk/src/engine/gncOwner.c
===================================================================
--- gnucash/trunk/src/engine/gncOwner.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/gncOwner.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -782,7 +782,7 @@
         xaccTransSetDescription (txn, name ? name : "");
         xaccTransSetNum (txn, num);
         xaccTransSetCurrency (txn, commodity);
-        xaccTransSetDateEnteredSecs (txn, time(NULL));
+        xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
         xaccTransSetDatePostedTS (txn, &date);
         xaccTransSetTxnType (txn, TXN_TYPE_PAYMENT);
 
@@ -952,7 +952,7 @@
 
                 xaccTransSetDescription (txn, name ? name : "");
                 xaccTransSetCurrency (txn, xaccAccountGetCommodity(acct));
-                xaccTransSetDateEnteredSecs (txn, time(NULL));
+                xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
                 xaccTransSetDatePostedTS (txn, &ts);
                 xaccTransSetTxnType (txn, TXN_TYPE_LINK);
             }

Modified: gnucash/trunk/src/engine/gncTaxTable.c
===================================================================
--- gnucash/trunk/src/engine/gncTaxTable.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/gncTaxTable.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -163,7 +163,7 @@
 static inline void
 mod_table (GncTaxTable *table)
 {
-    timespecFromTime_t (&table->modtime, time(NULL));
+    timespecFromTime64 (&table->modtime, gnc_time (NULL));
 }
 
 static inline void addObj (GncTaxTable *table)

Modified: gnucash/trunk/src/engine/test/test-transaction-voiding.c
===================================================================
--- gnucash/trunk/src/engine/test/test-transaction-voiding.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/test/test-transaction-voiding.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -57,7 +57,7 @@
     gnc_numeric old_amt, new_amt, old_val, new_val;
     QofBook *book;
     Timespec ts;
-    time_t now;
+    time64 now;
 
     char *reason = "because I can";
 
@@ -91,7 +91,7 @@
     old_amt = xaccSplitGetAmount(xaccTransGetSplit(transaction, 0));
     old_val = xaccSplitGetValue(xaccTransGetSplit(transaction, 1));
 
-    now = time (NULL);
+    now = gnc_time (NULL);
 
     xaccTransVoid(transaction, reason);
 

Modified: gnucash/trunk/src/engine/test/utest-Account.c
===================================================================
--- gnucash/trunk/src/engine/test/utest-Account.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/test/utest-Account.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -24,6 +24,7 @@
 #include <glib.h>
 #include <unittest-support.h>
 #include <gnc-event.h>
+#include <gnc-gdate-utils.h>
 /* Add specific headers for this class */
 #include "../Account.h"
 #include "../AccountP.h"
@@ -344,7 +345,7 @@
         Transaction *txn = xaccMallocTransaction (book);
         TxnParms p = t_arr[ind];
         GDate *date = g_date_new ();
-        g_date_set_time_t (date, time (0));
+        gnc_gdate_set_time64 (date, gnc_time (NULL));
         xaccTransBeginEdit (txn);
         if (p.desc)
             xaccTransSetDescription (txn, p.desc);
@@ -1872,7 +1873,7 @@
 }
 /* xaccAccountGetBalanceAsOfDate
 gnc_numeric
-xaccAccountGetBalanceAsOfDate (Account *acc, time_t date)// C: 12 in 7 SCM: 4 in 4*/
+xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)// C: 12 in 7 SCM: 4 in 4*/
 static void
 test_xaccAccountGetBalanceAsOfDate (Fixture *fixture, gconstpointer pData)
 {
@@ -1893,7 +1894,8 @@
     }
     dbal = gnc_numeric_to_double (bal);
     xaccAccountRecomputeBalance (fixture->acct);
-    val = xaccAccountGetBalanceAsOfDate (fixture->acct, (time (0) - offset));
+    val = xaccAccountGetBalanceAsOfDate (fixture->acct,
+					 (gnc_time (NULL) - offset));
     dval = gnc_numeric_to_double (val);
     g_assert_cmpfloat (dval, == , dbal);
 }

Modified: gnucash/trunk/src/engine/test/utest-Budget.c
===================================================================
--- gnucash/trunk/src/engine/test/utest-Budget.c	2012-12-01 22:44:41 UTC (rev 22620)
+++ gnucash/trunk/src/engine/test/utest-Budget.c	2012-12-01 22:44:53 UTC (rev 22621)
@@ -340,7 +340,7 @@
         Transaction *txn = xaccMallocTransaction (book);
         TxnParms p = t_arr[ind];
         GDate *date = g_date_new ();
-        g_date_set_time_t (date, time (0));
+        gnc_gdate_set_time64 (date, gnc_time (NULL));
         xaccTransBeginEdit (txn);
         if (p.desc)
             xaccTransSetDescription (txn, p.desc);
@@ -1868,7 +1868,7 @@
 }
 /* xaccAccountGetBalanceAsOfDate
 gnc_numeric
-xaccAccountGetBalanceAsOfDate (Account *acc, time_t date)// C: 12 in 7 SCM: 4 in 4*/
+xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)// C: 12 in 7 SCM: 4 in 4*/
 static void
 test_xaccAccountGetBalanceAsOfDate (Fixture *fixture, gconstpointer pData)
 {
@@ -1889,7 +1889,8 @@
     }
     dbal = gnc_numeric_to_double (bal);
     xaccAccountRecomputeBalance (fixture->acct);
-    val = xaccAccountGetBalanceAsOfDate (fixture->acct, (time (0) - offset));
+    val = xaccAccountGetBalanceAsOfDate (fixture->acct,
+					 (gnc_time (NULL) - offset));
     dval = gnc_numeric_to_double (val);
     g_assert_cmpfloat (dval, == , dbal);
 }



More information about the gnucash-changes mailing list