From f23eccfcd03d163294d476feb03c96ae9a4e89ed Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 1 Dec 2012 22:44:22 +0000 Subject: [PATCH] Convert all time_t to time64: core-utils git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22618 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/core-utils/gnc-gdate-utils.c | 19 +++++++++---------- src/core-utils/gnc-gdate-utils.h | 26 +++++++++++++++++++++----- src/core-utils/gnc-jalali.c | 7 +++---- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/core-utils/gnc-gdate-utils.c b/src/core-utils/gnc-gdate-utils.c index 221e670cc0..482f186882 100644 --- a/src/core-utils/gnc-gdate-utils.c +++ b/src/core-utils/gnc-gdate-utils.c @@ -23,7 +23,6 @@ #include "config.h" #include -#include #include "gnc-gdate-utils.h" @@ -63,25 +62,25 @@ gnc_gdate_hash( gconstpointer gd ) } -time_t -gnc_timet_get_day_start_gdate (GDate *date) +time64 +gnc_time64_get_day_start_gdate (const GDate *date) { struct tm stm; - time_t secs; + time64 secs; /* First convert to a 'struct tm' */ - g_date_to_struct_tm(date, &stm); + g_date_to_struct_tm (date, &stm); /* Then convert to number of seconds */ - secs = mktime (&stm); + secs = gnc_mktime (&stm); return secs; } -time_t -gnc_timet_get_day_end_gdate (GDate *date) +time64 +gnc_time64_get_day_end_gdate (const GDate *date) { struct tm stm; - time_t secs; + time64 secs; /* First convert to a 'struct tm' */ g_date_to_struct_tm(date, &stm); @@ -93,7 +92,7 @@ gnc_timet_get_day_end_gdate (GDate *date) stm.tm_isdst = -1; /* Then convert to number of seconds */ - secs = mktime (&stm); + secs = gnc_mktime (&stm); return secs; } diff --git a/src/core-utils/gnc-gdate-utils.h b/src/core-utils/gnc-gdate-utils.h index 479d2b14b0..a9e3c74461 100644 --- a/src/core-utils/gnc-gdate-utils.h +++ b/src/core-utils/gnc-gdate-utils.h @@ -38,6 +38,22 @@ #ifndef GNC_GDATE_UTILS_H #define GNC_GDATE_UTILS_H +#include + +/** @name GDate time64 setters + @{ */ +/** Set a GDate to the current day + * @param theGDate: The date to act on + */ +void gnc_gdate_set_today (GDate* gd); + +/** Set a GDate to a time64 + * @param theGDate: the date to act on + * @param time: the time to set it to. + */ +void gnc_gdate_set_time64 (GDate* gd, time64 time); + +/** @} */ /** @name GDate hash table support @{ */ @@ -53,18 +69,18 @@ guint gnc_gdate_hash( gconstpointer gd ); /** @} */ -/** @name GDate to time_t conversions +/** @name GDate to time64 conversions @{ */ -/** The gnc_timet_get_day_start() routine will take the given time in +/** The gnc_time64_get_day_start() routine will take the given time in * GLib GDate format and adjust it to the first second of that day. */ -time_t gnc_timet_get_day_start_gdate (GDate *date); +time64 gnc_time64_get_day_start_gdate (const GDate *date); -/** The gnc_timet_get_day_end() routine will take the given time in +/** The gnc_time64_get_day_end() routine will take the given time in * GLib GDate format and adjust it to the last second of that day. */ -time_t gnc_timet_get_day_end_gdate (GDate *date); +time64 gnc_time64_get_day_end_gdate (const GDate *date); /** @} */ diff --git a/src/core-utils/gnc-jalali.c b/src/core-utils/gnc-jalali.c index 427f51c8b2..8f33b42946 100644 --- a/src/core-utils/gnc-jalali.c +++ b/src/core-utils/gnc-jalali.c @@ -42,7 +42,6 @@ #include #include -#include #include int g_days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; @@ -179,11 +178,11 @@ int main(void) { int y, m, d; - time_t bin_time; + time64 bin_time; struct tm *br_time; - time(&bin_time); - br_time = localtime(&bin_time); + gnc_time (&bin_time); + br_time = gnc_localtime (&bin_time); gregorian_to_jalali(&y, &m, &d, 1900 + br_time->tm_year,