Convert all time_t to time64: backend

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22623 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls
2012-12-01 22:45:13 +00:00
parent 3f303811b2
commit 2a62fb551a
5 changed files with 22 additions and 30 deletions
+13 -13
View File
@@ -2009,8 +2009,7 @@ row_get_value_at_col_name( GncSqlRow* row, const gchar* col_name )
gushort type;
guint attrs;
GValue* value;
time_t time;
struct tm tm_struct;
time64 time;
type = dbi_result_get_field_type( dbi_row->result, col_name );
attrs = dbi_result_get_field_attribs( dbi_row->result, col_name );
@@ -2056,20 +2055,21 @@ row_get_value_at_col_name( GncSqlRow* row, const gchar* col_name )
creates a string that GDate can't parse. */
if (time >= 0)
{
(void)gmtime_r( &time, &tm_struct );
(void)g_value_init( value, G_TYPE_STRING );
g_value_take_string( value,
g_strdup_printf( "%d%02d%02d%02d%02d%02d",
1900 + tm_struct.tm_year,
tm_struct.tm_mon + 1,
tm_struct.tm_mday,
tm_struct.tm_hour,
tm_struct.tm_min,
tm_struct.tm_sec ) );
struct tm *tm_struct = gnc_gmtime (&time);
(void)g_value_init (value, G_TYPE_STRING);
g_value_take_string (value,
g_strdup_printf ("%d%02d%02d%02d%02d%02d",
1900 + tm_struct->tm_year,
tm_struct->tm_mon + 1,
tm_struct->tm_mday,
tm_struct->tm_hour,
tm_struct->tm_min,
tm_struct->tm_sec));
gnc_tm_free (tm_struct);
}
else
g_value_take_string (value, "19691231235959");
break;
default:
PERR( "Field %s: unknown DBI_TYPE: %d\n", col_name, type );
+5 -5
View File
@@ -1900,19 +1900,19 @@ typedef void (*TimespecSetterFunc)( const gpointer, Timespec );
gchar*
gnc_sql_convert_timespec_to_string( const GncSqlBackend* be, Timespec ts )
{
time_t time;
time64 time;
struct tm* tm;
gint year;
gchar* datebuf;
time = timespecToTime_t( ts );
tm = gmtime( &time );
time = timespecToTime64( ts );
tm = gnc_gmtime( &time );
if ( tm->tm_year < 60 ) year = tm->tm_year + 2000;
else year = tm->tm_year + 1900;
year = tm->tm_year + 1900;
datebuf = g_strdup_printf( be->timespec_format,
year, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec );
gnc_tm_free (tm);
return datebuf;
}
+1 -7
View File
@@ -633,13 +633,7 @@ test_gnc_sql_convert_timespec_to_string ()
Timespec *ts = gnc_date_string_to_timespec_gmt (date[i]);
gchar *datestr = gnc_sql_convert_timespec_to_string (&be, *ts);
if (i < 3)
g_assert_cmpstr (date[i], ==, datestr);
/* Dates before 1960 fail regardless of time_t */
else if (sizeof (time_t) > 4 && i > 3)
g_assert_cmpstr (date[i], ==, datestr);
else
g_assert_cmpstr (date[i], !=, datestr);
g_assert_cmpstr (date[i], ==, datestr);
g_free (datestr);
g_slice_free (Timespec, ts);
+2 -2
View File
@@ -857,7 +857,7 @@ gnc_xml_be_remove_old_files(FileBackend *be)
const gchar *dent;
GDir *dir;
struct stat lockstatbuf, statbuf;
time_t now;
time64 now;
if (g_stat (be->lockfile, &lockstatbuf) != 0)
return;
@@ -866,7 +866,7 @@ gnc_xml_be_remove_old_files(FileBackend *be)
if (!dir)
return;
now = time(NULL);
now = gnc_time(NULL);
while ((dent = g_dir_read_name(dir)) != NULL)
{
gchar *name;
+1 -3
View File
@@ -412,7 +412,7 @@ string_to_timespec_secs(const gchar *str, Timespec *ts)
struct tm parsed_time;
const gchar *strpos;
time_t parsed_secs;
time64 parsed_secs;
long int gmtoff;
if (!str || !ts) return FALSE;
@@ -458,8 +458,6 @@ string_to_timespec_secs(const gchar *str, Timespec *ts)
parsed_secs = gnc_timegm(&parsed_time);
if (parsed_secs == (time_t) - 1) return(FALSE);
parsed_secs -= gmtoff;
ts->tv_sec = parsed_secs;