r22624 - gnucash/trunk/src/import-export - Convert all time_t to time64: import-export
John Ralls
jralls at code.gnucash.org
Sat Dec 1 17:45:23 EST 2012
Author: jralls
Date: 2012-12-01 17:45:23 -0500 (Sat, 01 Dec 2012)
New Revision: 22624
Trac: http://svn.gnucash.org/trac/changeset/22624
Modified:
gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c
gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c
gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c
gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h
gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c
gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h
gnucash/trunk/src/import-export/import-backend.c
gnucash/trunk/src/import-export/ofx/gnc-ofx-import.c
Log:
Convert all time_t to time64: import-export
Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c 2012-12-01 22:45:13 UTC (rev 22623)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c 2012-12-01 22:45:23 UTC (rev 22624)
@@ -51,7 +51,7 @@
GWEN_TIME **from_date, GWEN_TIME **to_date)
{
Timespec last_timespec, until_timespec;
- time_t now = time(NULL);
+ time64 now = gnc_time (NULL);
gboolean use_last_date = TRUE;
gboolean use_earliest_date = TRUE;
gboolean use_until_now = TRUE;
@@ -63,9 +63,9 @@
if (last_timespec.tv_sec == 0)
{
use_last_date = FALSE;
- timespecFromTime_t(&last_timespec, now);
+ timespecFromTime64 (&last_timespec, now);
}
- timespecFromTime_t(&until_timespec, now);
+ timespecFromTime64 (&until_timespec, now);
/* Let the user choose the date range of retrieval */
if (!gnc_ab_enter_daterange(parent, NULL,
@@ -83,13 +83,13 @@
{
if (use_last_date)
last_timespec = gnc_ab_get_account_trans_retrieval(gnc_acc);
- *from_date = GWEN_Time_fromSeconds(timespecToTime_t(last_timespec));
+ *from_date = GWEN_Time_fromSeconds(timespecToTime64(last_timespec));
}
/* Now calculate to date */
if (use_until_now)
- timespecFromTime_t(&until_timespec, now);
- *to_date = GWEN_Time_fromSeconds(timespecToTime_t(until_timespec));
+ timespecFromTime64(&until_timespec, now);
+ *to_date = GWEN_Time_fromSeconds(timespecToTime64(until_timespec));
return TRUE;
}
@@ -145,7 +145,7 @@
goto cleanup;
}
/* Use this as a local storage for the until_time below. */
- timespecFromTime_t(&until_timespec, GWEN_Time_toTime_t(to_date));
+ timespecFromTime64(&until_timespec, GWEN_Time_toTime_t(to_date));
/* Get a GetTransactions job and enqueue it */
job = AB_JobGetTransactions_new(ab_acc);
Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c 2012-12-01 22:45:13 UTC (rev 22623)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c 2012-12-01 22:45:23 UTC (rev 22624)
@@ -470,7 +470,7 @@
Transaction *gnc_trans;
const gchar *fitid;
const GWEN_TIME *valuta_date;
- time_t current_time;
+ time64 current_time;
const char *custref;
gchar *description;
Split *split;
@@ -496,8 +496,7 @@
else
g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");
- current_time = time(NULL);
- xaccTransSetDateEnteredSecs(gnc_trans, mktime(localtime(¤t_time)));
+ xaccTransSetDateEnteredSecs(gnc_trans, gnc_time_utc (NULL));
/* Currency. We take simply the default currency of the gnucash account */
xaccTransSetCurrency(gnc_trans, xaccAccountGetCommodity(gnc_acc));
@@ -804,7 +803,7 @@
const AB_VALUE *booked_val = NULL, *noted_val = NULL;
gdouble booked_value, noted_value;
gnc_numeric value;
- time_t booked_tt = 0;
+ time64 booked_tt = 0;
GtkWidget *dialog;
gboolean show_recn_window = FALSE;
@@ -873,7 +872,7 @@
{
/* No time found? Use today because the HBCI query asked for today's
* balance. */
- booked_tt = gnc_timet_get_day_start(time(NULL));
+ booked_tt = gnc_time64_get_day_start(gnc_time(NULL));
}
booked_val = AB_Balance_GetValue(booked_bal);
if (booked_val)
Modified: gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c
===================================================================
--- gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c 2012-12-01 22:45:13 UTC (rev 22623)
+++ gnucash/trunk/src/import-export/csv-export/assistant-csv-export.c 2012-12-01 22:45:23 UTC (rev 22624)
@@ -480,19 +480,19 @@
static void
get_filter_times (CsvExportInfo *info)
{
- time_t time_val;
+ time64 time_val;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_choose)))
{
time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(info->csvd.start_date));
- time_val = gnc_timet_get_day_start(time_val);
+ time_val = gnc_time64_get_day_start(time_val);
info->csvd.start_time = time_val;
}
else
{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
{
- info->csvd.start_time = gnc_timet_get_today_start();
+ info->csvd.start_time = gnc_time64_get_today_start();
}
else
{
@@ -503,18 +503,18 @@
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.end_date_choose)))
{
time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(info->csvd.end_date));
- time_val = gnc_timet_get_day_end(time_val);
+ time_val = gnc_time64_get_day_end(time_val);
info->csvd.end_time = time_val;
}
else
{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
{
- info->csvd.end_time = gnc_timet_get_today_end();
+ info->csvd.end_time = gnc_time64_get_today_end();
}
else
{
- info->csvd.end_time = time(NULL);
+ info->csvd.end_time = gnc_time (NULL);
}
}
}
@@ -613,13 +613,13 @@
* a query and sorting by date. Since the truncated sort returns
* only the *last* search results, sort in decreasing order.
*******************************************************************/
-static time_t
+static time64
get_earliest_in_book (QofBook *book)
{
QofQuery *q;
GSList *p1, *p2;
GList *res;
- time_t earliest;
+ time64 earliest;
q = qof_query_create_for(GNC_ID_SPLIT);
qof_query_set_max_results(q, 1);
@@ -644,7 +644,7 @@
else
{
/* If no results, we don't want to bomb totally */
- earliest = time (0);
+ earliest = gnc_time (0);
}
qof_query_destroy (q);
@@ -856,7 +856,7 @@
GtkWidget *box, *h_box;
GtkWidget *button;
GtkWidget *table, *hbox;
- time_t start_time, end_time;
+ time64 start_time, end_time;
builder = gtk_builder_new();
gnc_builder_add_from_file (builder , "assistant-csv-export.glade", "CSV Export Assistant");
@@ -939,7 +939,7 @@
/* Earliest and Latest in Book */
start_time = get_earliest_in_book (gnc_get_current_book());
- end_time = time(NULL);
+ end_time = gnc_time (NULL);
info->csvd.start_time = start_time;
info->csvd.end_time = end_time;
@@ -955,20 +955,20 @@
info->csvd.end_date_today = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_today"));
/* Start date info */
- info->csvd.start_date = gnc_date_edit_new (time (NULL), FALSE, FALSE);
+ info->csvd.start_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_hbox"));
gtk_box_pack_start (GTK_BOX (hbox), info->csvd.start_date, TRUE, TRUE, 0);
gtk_widget_show (info->csvd.start_date);
- gnc_date_edit_set_time(GNC_DATE_EDIT(info->csvd.start_date), start_time);
+ gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.start_date), start_time);
g_signal_connect (G_OBJECT (info->csvd.start_date), "date-changed",
G_CALLBACK (csv_export_date_changed_cb), info);
/* End date info */
- info->csvd.end_date = gnc_date_edit_new (time (NULL), FALSE, FALSE);
+ info->csvd.end_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_hbox"));
gtk_box_pack_start (GTK_BOX (hbox), info->csvd.end_date, TRUE, TRUE, 0);
gtk_widget_show (info->csvd.end_date);
- gnc_date_edit_set_time(GNC_DATE_EDIT(info->csvd.end_date), end_time);
+ gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.end_date), end_time);
g_signal_connect (G_OBJECT (info->csvd.end_date), "date-changed",
G_CALLBACK (csv_export_date_changed_cb), info);
Modified: gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h
===================================================================
--- gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h 2012-12-01 22:45:13 UTC (rev 22623)
+++ gnucash/trunk/src/import-export/csv-export/assistant-csv-export.h 2012-12-01 22:45:23 UTC (rev 22624)
@@ -46,8 +46,8 @@
GtkWidget *end_date_today;
GtkWidget *end_date;
- time_t start_time;
- time_t end_time;
+ time64 start_time;
+ time64 end_time;
} CsvExportDate;
typedef struct
Modified: gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c 2012-12-01 22:45:13 UTC (rev 22623)
+++ gnucash/trunk/src/import-export/csv-import/gnc-csv-model.c 2012-12-01 22:45:23 UTC (rev 22624)
@@ -14,7 +14,6 @@
#include "gnc-ui-util.h"
#include <string.h>
-#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -23,10 +22,6 @@
#include <fcntl.h>
#include <stdlib.h>
#include <math.h>
-#include <time.h>
-#ifndef HAVE_LOCALTIME_R
-#include "localtime_r.h"
-#endif
G_GNUC_UNUSED static QofLogModule log_module = GNC_MOD_IMPORT;
@@ -74,9 +69,9 @@
* @param format An index specifying a format in date_format_user
* @return The parsed value of date_str on success or -1 on failure
*/
-static time_t parse_date_with_year(const char* date_str, int format)
+static time64 parse_date_with_year(const char* date_str, int format)
{
- time_t rawtime; /* The integer time */
+ time64 rawtime; /* The integer time */
struct tm retvalue, test_retvalue; /* The time in a broken-down structure */
int i, j, mem_length, orig_year = -1, orig_month = -1, orig_day = -1;
@@ -135,8 +130,8 @@
/* Put some sane values in retvalue by using the current time for
* the non-year-month-day parts of the date. */
- time(&rawtime);
- localtime_r(&rawtime, &retvalue);
+ gnc_time (&rawtime);
+ gnc_localtime_r (&rawtime, &retvalue);
/* j traverses pmatch (index 0 contains the entire string, so we
* start at index 1 for the first meaningful match). */
@@ -156,7 +151,7 @@
date_segment[mem_length] = '\0';
/* Set the appropriate member of retvalue. Save the original
- * values so that we can check if the change when we use mktime
+ * values so that we can check if the change when we use gnc_mktime
* below. */
switch (segment_type)
{
@@ -186,16 +181,16 @@
j++;
}
}
- /* Convert back to an integer. If mktime leaves retvalue unchanged,
+ /* Convert back to an integer. If gnc_mktime leaves retvalue unchanged,
* everything is okay; otherwise, an error has occurred. */
/* We have to use a "test" date value to account for changes in
- * daylight savings time, which can cause a date change with mktime
+ * daylight savings time, which can cause a date change with gnc_mktime
* near midnight, causing the code to incorrectly think a date is
* incorrect. */
test_retvalue = retvalue;
- mktime(&test_retvalue);
+ gnc_mktime (&test_retvalue);
retvalue.tm_isdst = test_retvalue.tm_isdst;
- rawtime = mktime(&retvalue);
+ rawtime = gnc_mktime (&retvalue);
if (retvalue.tm_mday == orig_day &&
retvalue.tm_mon == orig_month &&
retvalue.tm_year == orig_year)
@@ -215,9 +210,9 @@
* @param format An index specifying a format in date_format_user
* @return The parsed value of date_str on success or -1 on failure
*/
-static time_t parse_date_without_year(const char* date_str, int format)
+static time64 parse_date_without_year(const char* date_str, int format)
{
- time_t rawtime; /* The integer time */
+ time64 rawtime; /* The integer time */
struct tm retvalue, test_retvalue; /* The time in a broken-down structure */
int i, j, mem_length, orig_year = -1, orig_month = -1, orig_day = -1;
@@ -245,8 +240,8 @@
/* Put some sane values in retvalue by using the current time for
* the non-year-month-day parts of the date. */
- time(&rawtime);
- localtime_r(&rawtime, &retvalue);
+ gnc_time (&rawtime);
+ gnc_localtime_r (&rawtime, &retvalue);
orig_year = retvalue.tm_year;
/* j traverses pmatch (index 0 contains the entire string, so we
@@ -268,7 +263,7 @@
date_segment[mem_length] = '\0';
/* Set the appropriate member of retvalue. Save the original
- * values so that we can check if the change when we use mktime
+ * values so that we can check if the change when we use gnc_mktime
* below. */
switch (segment_type)
{
@@ -284,16 +279,16 @@
j++;
}
}
- /* Convert back to an integer. If mktime leaves retvalue unchanged,
+ /* Convert back to an integer. If gnc_mktime leaves retvalue unchanged,
* everything is okay; otherwise, an error has occurred. */
/* We have to use a "test" date value to account for changes in
- * daylight savings time, which can cause a date change with mktime
+ * daylight savings time, which can cause a date change with gnc_mktime
* near midnight, causing the code to incorrectly think a date is
* incorrect. */
test_retvalue = retvalue;
- mktime(&test_retvalue);
+ gnc_mktime (&test_retvalue);
retvalue.tm_isdst = test_retvalue.tm_isdst;
- rawtime = mktime(&retvalue);
+ rawtime = gnc_mktime (&retvalue);
if (retvalue.tm_mday == orig_day &&
retvalue.tm_mon == orig_month &&
retvalue.tm_year == orig_year)
@@ -314,7 +309,7 @@
* @param format An index specifying a format in date_format_user
* @return The parsed value of date_str on success or -1 on failure
*/
-time_t parse_date(const char* date_str, int format)
+time64 parse_date(const char* date_str, int format)
{
if (strchr(date_format_user[format], 'y'))
return parse_date_with_year(date_str, format);
@@ -625,7 +620,7 @@
{
switch (prop->type)
{
- /* The types for "Date" and "Balance" (time_t and gnc_numeric,
+ /* The types for "Date" and "Balance" (time64 and gnc_numeric,
* respectively) are typically not pointed to, we have to free
* them, unlike types like char* ("Description"). */
case GNC_CSV_DATE:
@@ -653,9 +648,9 @@
switch (prop->type)
{
case GNC_CSV_DATE:
- prop->value = g_new(time_t, 1);
- *((time_t*)(prop->value)) = parse_date(str, prop->list->date_format);
- return *((time_t*)(prop->value)) != -1;
+ prop->value = g_new(time64, 1);
+ *((time64*)(prop->value)) = parse_date(str, prop->list->date_format);
+ return *((time64*)(prop->value)) != -1;
case GNC_CSV_DESCRIPTION:
case GNC_CSV_NOTES:
@@ -924,7 +919,7 @@
switch (prop->type)
{
case GNC_CSV_DATE:
- xaccTransSetDatePostedSecs(trans_line->trans, *((time_t*)(prop->value)));
+ xaccTransSetDatePostedSecs(trans_line->trans, *((time64*)(prop->value)));
break;
case GNC_CSV_DESCRIPTION:
@@ -1202,7 +1197,7 @@
GncCsvTransLine* trans_line = (GncCsvTransLine*)transactions->data;
if (trans_line->balance_set)
{
- time_t date = xaccTransGetDate(trans_line->trans);
+ time64 date = xaccTransGetDate(trans_line->trans);
/* Find what the balance should be by adding the offset to the actual balance. */
gnc_numeric existing_balance = gnc_numeric_add(balance_offset,
xaccAccountGetBalanceAsOfDate(account, date),
Modified: gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h
===================================================================
--- gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h 2012-12-01 22:45:13 UTC (rev 22623)
+++ gnucash/trunk/src/import-export/csv-import/gnc-csv-model.h 2012-12-01 22:45:23 UTC (rev 22624)
@@ -130,6 +130,6 @@
int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account, gboolean redo_errors);
-time_t parse_date(const char* date_str, int format);
+time64 parse_date(const char* date_str, int format);
#endif
Modified: gnucash/trunk/src/import-export/import-backend.c
===================================================================
--- gnucash/trunk/src/import-export/import-backend.c 2012-12-01 22:45:13 UTC (rev 22623)
+++ gnucash/trunk/src/import-export/import-backend.c 2012-12-01 22:45:23 UTC (rev 22624)
@@ -409,7 +409,7 @@
Transaction* transaction;
GList* tokens;
const char* text;
- time_t transtime;
+ time64 transtime;
struct tm *tm_struct;
char local_day_of_week[16];
Split* split;
@@ -432,12 +432,12 @@
* it to day of week as a token
*/
transtime = xaccTransGetDate(transaction);
- tm_struct = gmtime(&transtime);
+ tm_struct = gnc_gmtime(&transtime);
if (!qof_strftime(local_day_of_week, sizeof(local_day_of_week), "%A", tm_struct))
{
PERR("TransactionGetTokens: error, strftime failed\n");
}
-
+ gnc_tm_free (tm_struct);
/* we cannot add a locally allocated string to this array, dup it so
* it frees the same way the rest do
*/
@@ -599,7 +599,7 @@
gint prob = 0;
gboolean update_proposed;
double downloaded_split_amount, match_split_amount;
- time_t match_time, download_time;
+ time64 match_time, download_time;
int datediff_day;
Transaction *new_trans = gnc_import_TransInfo_get_trans (trans_info);
Split *new_trans_fsplit = gnc_import_TransInfo_get_fsplit (trans_info);
@@ -816,7 +816,7 @@
*/
Account *importaccount =
xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (trans_info));
- time_t download_time = xaccTransGetDate (gnc_import_TransInfo_get_trans (trans_info));
+ time64 download_time = xaccTransGetDate (gnc_import_TransInfo_get_trans (trans_info));
qof_query_set_book (query, gnc_get_current_book());
xaccQueryAddSingleAccountMatch (query, importaccount,
@@ -917,7 +917,7 @@
xaccSplitSetReconcile(gnc_import_TransInfo_get_fsplit (trans_info), CREC);
/*Set reconcile date to today*/
xaccSplitSetDateReconciledSecs(gnc_import_TransInfo_get_fsplit (trans_info),
- time(NULL));
+ gnc_time (NULL));
/* Done editing. */
xaccTransCommitEdit(gnc_import_TransInfo_get_trans (trans_info));
return TRUE;
@@ -981,7 +981,7 @@
}
/* Set reconcile date to today */
- xaccSplitSetDateReconciledSecs(selected_match->split, time(NULL));
+ xaccSplitSetDateReconciledSecs(selected_match->split, gnc_time (NULL));
/* Copy the online id to the reconciled transaction, so
the match will be remembered */
@@ -1037,7 +1037,7 @@
(selected_match->split, CREC);
/* Set reconcile date to today */
xaccSplitSetDateReconciledSecs
- (selected_match->split, time(NULL));
+ (selected_match->split, gnc_time (NULL));
/* Copy the online id to the reconciled transaction, so
the match will be remembered */
Modified: gnucash/trunk/src/import-export/ofx/gnc-ofx-import.c
===================================================================
--- gnucash/trunk/src/import-export/ofx/gnc-ofx-import.c 2012-12-01 22:45:13 UTC (rev 22623)
+++ gnucash/trunk/src/import-export/ofx/gnc-ofx-import.c 2012-12-01 22:45:23 UTC (rev 22624)
@@ -313,7 +313,7 @@
int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_user_data)
{
char dest_string[255];
- time_t current_time;
+ time64 current_time = gnc_time (NULL);
Account *account;
Account *investment_account = NULL;
Account *income_account = NULL;
@@ -375,11 +375,10 @@
else
{
/* Uh no, no valid date. As a workaround use today's date */
- xaccTransSetDatePostedSecs(transaction, mktime(localtime(¤t_time)));
+ xaccTransSetDatePostedSecs(transaction, current_time);
}
- current_time = time(NULL);
- xaccTransSetDateEnteredSecs(transaction, mktime(localtime(¤t_time)));
+ xaccTransSetDateEnteredSecs(transaction, current_time);
if (data.check_number_valid)
{
@@ -426,7 +425,7 @@
if (data.date_funds_available_valid)
{
Timespec ts;
- timespecFromTime_t(&ts, data.date_funds_available);
+ timespecFromTime64(&ts, data.date_funds_available);
gnc_timespec_to_iso8601_buff (ts, dest_string);
tmp = notes;
notes = g_strdup_printf("%s%s%s", tmp, "|Date funds available:", dest_string);
More information about the gnucash-changes
mailing list