r22620 - gnucash/trunk/src/app-utils - Convert all time_t to time64: app-utils
John Ralls
jralls at code.gnucash.org
Sat Dec 1 17:44:41 EST 2012
Author: jralls
Date: 2012-12-01 17:44:41 -0500 (Sat, 01 Dec 2012)
New Revision: 22620
Trac: http://svn.gnucash.org/trac/changeset/22620
Modified:
gnucash/trunk/src/app-utils/gnc-accounting-period.c
gnucash/trunk/src/app-utils/gnc-accounting-period.h
gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
gnucash/trunk/src/app-utils/gnc-ui-balances.c
gnucash/trunk/src/app-utils/gnc-ui-balances.h
gnucash/trunk/src/app-utils/gnc-ui-util.c
gnucash/trunk/src/app-utils/gnc-ui-util.h
gnucash/trunk/src/app-utils/guile-util.c
gnucash/trunk/src/app-utils/guile-util.h
gnucash/trunk/src/app-utils/option-util.c
gnucash/trunk/src/app-utils/option-util.h
gnucash/trunk/src/app-utils/test/test-sx.c
Log:
Convert all time_t to time64: app-utils
Modified: gnucash/trunk/src/app-utils/gnc-accounting-period.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-accounting-period.c 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/gnc-accounting-period.c 2012-12-01 22:44:41 UTC (rev 22620)
@@ -59,7 +59,14 @@
#define KEY_END_DATE "end_date"
#define KEY_END_PERIOD "end_period"
-static time_t
+static time64 gnc_accounting_period_start_time64 (GncAccountingPeriod which,
+ const GDate *fy_end,
+ const GDate *contains);
+static time64 gnc_accounting_period_end_time64 (GncAccountingPeriod which,
+ const GDate *fy_end,
+ const GDate *contains);
+
+static time64
lookup_start_date_option(const gchar *section,
const gchar *key_choice,
const gchar *key_absolute,
@@ -67,7 +74,7 @@
GDate *fy_end)
{
gchar *choice;
- time_t time;
+ time64 time;
int which;
choice = gnc_gconf_get_string(section, key_choice, NULL);
@@ -78,7 +85,7 @@
else
{
which = gnc_gconf_get_int(section, key_relative, NULL);
- time = gnc_accounting_period_start_timet(which, fy_end, NULL);
+ time = gnc_accounting_period_start_time64(which, fy_end, NULL);
}
g_free(choice);
/* we will need the balance of the last transaction before the start
@@ -88,8 +95,7 @@
return time;
}
-
-static time_t
+static time64
lookup_end_date_option(const gchar *section,
const gchar *key_choice,
const gchar *key_absolute,
@@ -97,19 +103,19 @@
GDate *fy_end)
{
gchar *choice;
- time_t time;
+ time64 time;
int which;
choice = gnc_gconf_get_string(section, key_choice, NULL);
if (choice && strcmp(choice, "absolute") == 0)
{
time = gnc_gconf_get_int(section, key_absolute, NULL);
- time = gnc_timet_get_day_end(time);
+ time = gnc_time64_get_day_end(time);
}
else
{
which = gnc_gconf_get_int(section, key_relative, NULL);
- time = gnc_accounting_period_end_timet(which, fy_end, NULL);
+ time = gnc_accounting_period_end_time64(which, fy_end, NULL);
}
g_free(choice);
if (time == 0)
@@ -133,10 +139,10 @@
return NULL;
}
-time_t
+time64
gnc_accounting_period_fiscal_start(void)
{
- time_t t;
+ time64 t;
GDate *fy_end = get_fy_end();
t = lookup_start_date_option(GCONF_SECTION, KEY_START_CHOICE,
KEY_START_DATE, KEY_START_PERIOD, fy_end);
@@ -145,10 +151,10 @@
return t;
}
-time_t
+time64
gnc_accounting_period_fiscal_end(void)
{
- time_t t;
+ time64 t;
GDate *fy_end = get_fy_end();
t = lookup_end_date_option(GCONF_SECTION, KEY_END_CHOICE,
@@ -173,8 +179,8 @@
}
else
{
- date = g_date_new();
- g_date_set_time_t(date, time(NULL));
+ date = g_date_new ();
+ gnc_gdate_set_today (date);
}
switch (which)
@@ -235,19 +241,19 @@
return date;
}
-time_t
-gnc_accounting_period_start_timet (GncAccountingPeriod which,
+static time64
+gnc_accounting_period_start_time64 (GncAccountingPeriod which,
const GDate *fy_end,
const GDate *contains)
{
GDate *date;
- time_t secs;
+ time64 secs;
date = gnc_accounting_period_start_gdate(which, fy_end, contains);
if (!date)
return 0;
- secs = gnc_timet_get_day_start_gdate(date);
+ secs = gnc_time64_get_day_start_gdate(date);
g_date_free(date);
return secs;
}
@@ -267,8 +273,8 @@
}
else
{
- date = g_date_new();
- g_date_set_time_t(date, time(NULL));
+ date = g_date_new ();
+ gnc_gdate_set_today (date);
}
switch (which)
@@ -330,22 +336,21 @@
return date;
}
-time_t
-gnc_accounting_period_end_timet (GncAccountingPeriod which,
+static time64
+gnc_accounting_period_end_time64 (GncAccountingPeriod which,
const GDate *fy_end,
const GDate *contains)
{
GDate *date;
- time_t secs;
+ time64 secs;
date = gnc_accounting_period_end_gdate(which, fy_end, contains);
if (!date)
return 0;
- secs = gnc_timet_get_day_end_gdate(date);
+ secs = gnc_time64_get_day_end_gdate(date);
g_date_free(date);
return secs ;
}
-
/** @} */
Modified: gnucash/trunk/src/app-utils/gnc-accounting-period.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-accounting-period.h 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/gnc-accounting-period.h 2012-12-01 22:44:41 UTC (rev 22620)
@@ -45,7 +45,7 @@
#define GNC_ACCOUNTING_PERIOD_H
#include <glib.h>
-#include <time.h>
+#include <gnc-date.h>
/**
* This specifies a time interval.
@@ -93,32 +93,6 @@
GDate *gnc_accounting_period_start_gdate (GncAccountingPeriod which,
const GDate *fy_end,
const GDate *contains);
-
-
-/** This function returns the starting time for an accounting period.
- * The time will be computed based upon the type of accounting
- * interval requested, an optional fiscal year end value, and an
- * optional time value.
- *
- * @param which An enum specifying the type of accounting period.
- *
- * @param fy_end This argument specifies the month and day of the
- * fiscal year end. If the accounting period specified in the
- * 'which' parameter is not a fiscal accounting period, this variable
- * is ignored and may be NULL. Note: the year field of this argument
- * is always ignored.
- *
- * @param contains This argument specifies the origin time value used
- * by the calculations in this function. If this value is NULL, the
- * origin will be the current time.
- *
- * @return The starting second of the specified time interval, based
- * on a zero value of January 1st, 1970. */
-time_t gnc_accounting_period_start_timet (GncAccountingPeriod which,
- const GDate *fy_end,
- const GDate *contains);
-
-
/** This function returns the ending date for an accounting period.
* The date will be computed based upon the type of accounting
* interval requested, an optional fiscal year end value, and an
@@ -142,35 +116,10 @@
const GDate *fy_end,
const GDate *contains);
-
-/** This function returns the ending time for an accounting period.
- * The time will be computed based upon the type of accounting
- * interval requested, an optional fiscal year end value, and an
- * optional time value.
- *
- * @param which An enum specifying the type of accounting period.
- *
- * @param fy_end This argument specifies the month and day of the
- * fiscal year end. If the accounting period specified in the
- * 'which' parameter is not a fiscal accounting period, this variable
- * is ignored and may be NULL. Note: the year field of this argument
- * is always ignored.
- *
- * @param contains This argument specifies the origin time value used
- * by the calculations in this function. If this value is NULL, the
- * origin will be the current time.
- *
- * @return The ending second of the specified time interval, based
- * on a zero value of January 1st, 1970. */
-time_t gnc_accounting_period_end_timet (GncAccountingPeriod which,
- const GDate *fy_end,
- const GDate *contains);
-
-
/* Get the fiscal accounting period from the preferences and return
the start and end times. */
-time_t gnc_accounting_period_fiscal_start(void);
-time_t gnc_accounting_period_fiscal_end(void);
+time64 gnc_accounting_period_fiscal_start(void);
+time64 gnc_accounting_period_fiscal_end(void);
/** @} */
Modified: gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-sx-instance-model.c 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/gnc-sx-instance-model.c 2012-12-01 22:44:41 UTC (rev 22620)
@@ -48,6 +48,7 @@
#include "gnc-sx-instance-model.h"
#include "gnc-ui-util.h"
#include "qof.h"
+#include <gnc-gdate-utils.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "gnc.app-utils.sx"
@@ -426,7 +427,7 @@
{
GDate now;
g_date_clear(&now, 1);
- g_date_set_time_t(&now, time(NULL));
+ gnc_gdate_set_time64 (&now, gnc_time (NULL));
return gnc_sx_get_instances(&now, FALSE);
}
Modified: gnucash/trunk/src/app-utils/gnc-ui-balances.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-balances.c 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/gnc-ui-balances.c 2012-12-01 22:44:41 UTC (rev 22620)
@@ -182,7 +182,7 @@
gnc_numeric
gnc_ui_account_get_balance_as_of_date (Account *account,
- time_t date,
+ time64 date,
gboolean include_children)
{
gnc_numeric balance;
Modified: gnucash/trunk/src/app-utils/gnc-ui-balances.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-balances.h 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/gnc-ui-balances.h 2012-12-01 22:44:41 UTC (rev 22620)
@@ -108,8 +108,8 @@
gboolean *negative);
gnc_numeric gnc_ui_account_get_balance_as_of_date (Account *account,
- time_t date,
- gboolean include_children);
+ time64 date,
+ gboolean include_children);
/********************************************************************
* Balance calculations related to owners
Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c 2012-12-01 22:44:41 UTC (rev 22620)
@@ -712,7 +712,7 @@
gboolean
gnc_account_create_opening_balance (Account *account,
gnc_numeric balance,
- time_t date,
+ time64 date,
QofBook *book)
{
Account *equity_account;
Modified: gnucash/trunk/src/app-utils/gnc-ui-util.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.h 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.h 2012-12-01 22:44:41 UTC (rev 22620)
@@ -126,7 +126,7 @@
gnc_commodity *currency);
gboolean gnc_account_create_opening_balance (Account *account,
gnc_numeric balance,
- time_t date,
+ time64 date,
QofBook *book);
/* Locale functions *************************************************/
Modified: gnucash/trunk/src/app-utils/guile-util.c
===================================================================
--- gnucash/trunk/src/app-utils/guile-util.c 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/guile-util.c 2012-12-01 22:44:41 UTC (rev 22620)
@@ -1304,8 +1304,8 @@
}
-time_t
-gnc_parse_time_to_timet(const gchar *s, const gchar *format)
+time64
+gnc_parse_time_to_time64 (const gchar *s, const gchar *format)
{
struct tm tm;
@@ -1314,7 +1314,7 @@
if (!strptime(s, format, &tm))
return -1;
- return mktime(&tm);
+ return gnc_mktime(&tm);
}
gchar *gnc_scm_to_locale_string(SCM scm_string)
Modified: gnucash/trunk/src/app-utils/guile-util.h
===================================================================
--- gnucash/trunk/src/app-utils/guile-util.h 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/guile-util.h 2012-12-01 22:44:41 UTC (rev 22620)
@@ -153,4 +153,4 @@
* @param format Format specification.
*
* @return The time in seconds since unix epoch, or -1 on error */
-time_t gnc_parse_time_to_timet(const gchar *s, const gchar *format);
+time64 gnc_parse_time_to_time64 (const gchar *s, const gchar *format);
Modified: gnucash/trunk/src/app-utils/option-util.c
===================================================================
--- gnucash/trunk/src/app-utils/option-util.c 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/option-util.c 2012-12-01 22:44:41 UTC (rev 22620)
@@ -2085,7 +2085,7 @@
* set_ab_value argument. If the default_value argument is NULL, *
* copies the current date to set_ab_value. Whatever value is *
* stored in set_ab_value is returned as an approximate (no *
- * nanoseconds) time_t value. set_ab_value may be NULL, in which *
+ * nanoseconds) time64 value. set_ab_value may be NULL, in which *
* case only the return value can be used. If is_relative is *
* non-NULL, it is set to whether the date option is currently *
* storing a relative date. If it is, and set_rel_value *
@@ -2099,9 +2099,9 @@
* set_ab_value - location to store absolute option value *
* set_rel_value - location to store relative option value *
* default - default value if not found *
- * Return: time_t approximation of set_value *
+ * Return: time64 approximation of set_value *
\********************************************************************/
-time_t
+time64
gnc_option_db_lookup_date_option(GNCOptionDB *odb,
const char *section,
const char *name,
@@ -2171,7 +2171,7 @@
{
if (default_value == NULL)
{
- set_ab_value->tv_sec = time (NULL);
+ set_ab_value->tv_sec = gnc_time (NULL);
set_ab_value->tv_nsec = 0;
}
else
Modified: gnucash/trunk/src/app-utils/option-util.h
===================================================================
--- gnucash/trunk/src/app-utils/option-util.h 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/option-util.h 2012-12-01 22:44:41 UTC (rev 22620)
@@ -182,7 +182,7 @@
const char *name,
const char *default_value);
-time_t gnc_option_db_lookup_date_option(GNCOptionDB *odb,
+time64 gnc_option_db_lookup_date_option(GNCOptionDB *odb,
const char *section,
const char *name,
gboolean *is_relative,
Modified: gnucash/trunk/src/app-utils/test/test-sx.c
===================================================================
--- gnucash/trunk/src/app-utils/test/test-sx.c 2012-12-01 22:44:31 UTC (rev 22619)
+++ gnucash/trunk/src/app-utils/test/test-sx.c 2012-12-01 22:44:41 UTC (rev 22620)
@@ -4,6 +4,7 @@
#include "SX-book.h"
#include "gnc-sx-instance-model.h"
#include "gnc-ui-util.h"
+#include <gnc-gdate-utils.h>
#include "test-stuff.h"
#include "test-engine-stuff.h"
@@ -16,7 +17,7 @@
SchedXaction *one_sx;
g_date_clear(&today, 1);
- g_date_set_time_t(&today, time(NULL));
+ gnc_gdate_set_today (&today);
yesterday = today;
g_date_subtract_days(&yesterday, 1);
@@ -86,14 +87,14 @@
when = g_date_new();
g_date_clear(when, 1);
- g_date_set_time_t(when, time(NULL));
+ gnc_gdate_set_today (when);
while (random_offset_within_one_year == 0)
random_offset_within_one_year = get_random_int_in_range(-365, 365);
g_date_add_days(when, random_offset_within_one_year);
end = g_date_new();
g_date_clear(end, 1);
- g_date_set_time_t(end, time(NULL));
+ gnc_gdate_set_today (end);
g_date_add_years(end, 1);
lonely = add_once_sx("once", when);
@@ -128,10 +129,10 @@
GncSxInstance *inst;
start = g_date_new();
- g_date_set_time_t(start, time(NULL));
+ gnc_gdate_set_today (start);
end = g_date_new();
- g_date_set_time_t(end, time(NULL));
+ gnc_gdate_set_today (end);
g_date_add_days(end, 3);
foo = add_daily_sx("foo", start, NULL, NULL);
More information about the gnucash-changes
mailing list