r22625 - gnucash/trunk/src - Convert all time_t to time64: gnome-utils and gnome-search
John Ralls
jralls at code.gnucash.org
Sat Dec 1 17:45:35 EST 2012
Author: jralls
Date: 2012-12-01 17:45:34 -0500 (Sat, 01 Dec 2012)
New Revision: 22625
Trac: http://svn.gnucash.org/trac/changeset/22625
Modified:
gnucash/trunk/src/gnome-search/search-date.c
gnucash/trunk/src/gnome-utils/dialog-account.c
gnucash/trunk/src/gnome-utils/dialog-book-close.c
gnucash/trunk/src/gnome-utils/dialog-dup-trans.c
gnucash/trunk/src/gnome-utils/dialog-dup-trans.h
gnucash/trunk/src/gnome-utils/dialog-preferences.c
gnucash/trunk/src/gnome-utils/dialog-transfer.c
gnucash/trunk/src/gnome-utils/dialog-transfer.h
gnucash/trunk/src/gnome-utils/dialog-utils.c
gnucash/trunk/src/gnome-utils/gnc-cell-renderer-date.c
gnucash/trunk/src/gnome-utils/gnc-cell-renderer-date.h
gnucash/trunk/src/gnome-utils/gnc-date-edit.c
gnucash/trunk/src/gnome-utils/gnc-date-edit.h
gnucash/trunk/src/gnome-utils/gnc-date-format.c
gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c
gnucash/trunk/src/gnome-utils/gnc-dense-cal.c
gnucash/trunk/src/gnome-utils/gnc-file.c
gnucash/trunk/src/gnome-utils/gnc-main-window.c
gnucash/trunk/src/gnome-utils/gnc-period-select.c
gnucash/trunk/src/gnome-utils/gnc-period-select.h
gnucash/trunk/src/gnome-utils/gnc-recurrence.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
gnucash/trunk/src/gnome-utils/window-main-summarybar.c
Log:
Convert all time_t to time64: gnome-utils and gnome-search
Modified: gnucash/trunk/src/gnome-search/search-date.c
===================================================================
--- gnucash/trunk/src/gnome-search/search-date.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-search/search-date.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -113,7 +113,7 @@
static void
gnc_search_date_init (GNCSearchDate *o)
{
- o->ts.tv_sec = time(NULL);
+ o->ts.tv_sec = gnc_time (NULL);
o->how = QOF_COMPARE_LT;
}
Modified: gnucash/trunk/src/gnome-utils/dialog-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-account.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/dialog-account.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -281,7 +281,7 @@
Account *account,
Account *transfer,
gnc_numeric balance,
- time_t date)
+ time64 date)
{
Transaction *trans;
Split *split;
@@ -341,7 +341,7 @@
gboolean flag;
gnc_numeric balance;
gboolean use_equity, nonstd;
- time_t date;
+ time64 date;
gint index, old_scu, new_scu;
GtkTextIter start, end;
@@ -1373,7 +1373,7 @@
gtk_label_set_mnemonic_widget (GTK_LABEL(label), amount);
box = GTK_WIDGET(gtk_builder_get_object (builder, "opening_balance_date_box"));
- date_edit = gnc_date_edit_new (time (NULL), 1, 1);
+ date_edit = gnc_date_edit_new (gnc_time (NULL), 1, 1);
aw->opening_balance_date_edit = date_edit;
gtk_box_pack_start(GTK_BOX(box), date_edit, TRUE, TRUE, 0);
gtk_widget_show (date_edit);
Modified: gnucash/trunk/src/gnome-utils/dialog-book-close.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-book-close.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/dialog-book-close.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -62,7 +62,7 @@
GtkWidget* desc_widget;
/* The final settings */
- time_t close_date;
+ time64 close_date;
const char* desc;
/* Component registration */
@@ -101,7 +101,7 @@
txn->total = gnc_numeric_zero();
txn->txn = xaccMallocTransaction(cacb->cbw->book);
xaccTransBeginEdit(txn->txn);
- xaccTransSetDateEnteredSecs(txn->txn, time(NULL));
+ xaccTransSetDateEnteredSecs(txn->txn, gnc_time (NULL));
xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
xaccTransSetDescription(txn->txn, cacb->cbw->desc);
xaccTransSetCurrency(txn->txn, cmdty);
@@ -336,7 +336,7 @@
/* close date */
box = GTK_WIDGET(gtk_builder_get_object (builder, "date_box"));
- cbw->close_date_widget = gnc_date_edit_new(time(NULL), FALSE, FALSE);
+ cbw->close_date_widget = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
gtk_box_pack_start(GTK_BOX(box), cbw->close_date_widget, TRUE, TRUE, 0);
/* income acct */
Modified: gnucash/trunk/src/gnome-utils/dialog-dup-trans.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-dup-trans.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/dialog-dup-trans.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -91,7 +91,7 @@
static void
gnc_dup_trans_dialog_create (GtkWidget * parent, DupTransDialog *dt_dialog,
- time_t date, const char *num_str)
+ time64 date, const char *num_str)
{
GtkWidget *dialog;
GtkBuilder *builder;
@@ -153,7 +153,7 @@
static gboolean
gnc_dup_trans_dialog_internal (GtkWidget * parent, const char* title,
- time_t *date_p, GDate *gdate_p,
+ time64 *date_p, GDate *gdate_p,
const char *num, char **out_num)
{
DupTransDialog *dt_dialog;
@@ -210,7 +210,7 @@
}
gboolean
-gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
+gnc_dup_trans_dialog (GtkWidget * parent, time64 *date_p,
const char *num, char **out_num)
{
return gnc_dup_trans_dialog_internal(parent, NULL, date_p, NULL, num, out_num);
@@ -220,19 +220,19 @@
gnc_dup_trans_dialog_gdate (GtkWidget * parent, GDate *gdate_p,
const char *num, char **out_num)
{
- time_t tmp_time;
+ time64 tmp_time;
g_assert(gdate_p);
- tmp_time = timespecToTime_t(gdate_to_timespec(*gdate_p));
+ tmp_time = timespecToTime64(gdate_to_timespec(*gdate_p));
return gnc_dup_trans_dialog_internal(parent, NULL, &tmp_time, gdate_p, num, out_num);
}
gboolean
gnc_dup_date_dialog (GtkWidget * parent, const char* title, GDate *gdate_p)
{
- time_t tmp_time;
+ time64 tmp_time;
g_assert(gdate_p);
- tmp_time = timespecToTime_t(gdate_to_timespec(*gdate_p));
+ tmp_time = timespecToTime64(gdate_to_timespec(*gdate_p));
return gnc_dup_trans_dialog_internal(parent, title, &tmp_time, gdate_p, NULL, NULL);
}
Modified: gnucash/trunk/src/gnome-utils/dialog-dup-trans.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-dup-trans.h 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/dialog-dup-trans.h 2012-12-01 22:45:34 UTC (rev 22625)
@@ -28,6 +28,7 @@
#define DIALOGDUPTRANS_H
#include <gtk/gtk.h>
+#include <gnc-date.h>
/********************************************************************\
@@ -42,7 +43,7 @@
* Return: TRUE if user closes dialog with 'OK' *
\********************************************************************/
gboolean
-gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
+gnc_dup_trans_dialog (GtkWidget * parent, time64 *date_p,
const char *num, char **out_num);
gboolean
Modified: gnucash/trunk/src/gnome-utils/dialog-preferences.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-preferences.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/dialog-preferences.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -1309,7 +1309,7 @@
gpointer user_data)
{
const gchar *name;
- time_t time;
+ time64 time;
g_return_if_fail(GNC_IS_DATE_EDIT(gde));
name = g_object_get_data(G_OBJECT(gde), "name");
@@ -1333,7 +1333,7 @@
gnc_prefs_date_edit_gconf_cb (GNCDateEdit *gde,
GConfEntry *entry)
{
- time_t time;
+ time64 time;
g_return_if_fail(GNC_IS_DATE_EDIT(gde));
ENTER("date_edit %p, entry %p", gde, entry);
@@ -1360,7 +1360,7 @@
gnc_prefs_connect_date_edit (GNCDateEdit *gde , const gchar *boxname )
{
const gchar *name;
- time_t time;
+ time64 time;
g_return_if_fail(GNC_IS_DATE_EDIT(gde));
@@ -1566,7 +1566,7 @@
gtk_box_pack_start (GTK_BOX (box), period, TRUE, TRUE, 0);
box = GTK_WIDGET(gtk_builder_get_object (builder, "gconf/window/pages/account_tree/summary/start_date"));
- date = gnc_date_edit_new(time(NULL), FALSE, FALSE);
+ date = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
gtk_widget_show (date);
gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);
@@ -1576,7 +1576,7 @@
gtk_box_pack_start (GTK_BOX (box), period, TRUE, TRUE, 0);
box = GTK_WIDGET(gtk_builder_get_object (builder, "gconf/window/pages/account_tree/summary/end_date"));
- date = gnc_date_edit_new(time(NULL), FALSE, FALSE);
+ date = gnc_date_edit_new(gnc_time (NULL), FALSE, FALSE);
gtk_widget_show (date);
gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);
Modified: gnucash/trunk/src/gnome-utils/dialog-transfer.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -1278,7 +1278,7 @@
* Return: none *
\********************************************************************/
void
-gnc_xfer_dialog_set_date(XferDialog *xferData, time_t set_date)
+gnc_xfer_dialog_set_date(XferDialog *xferData, time64 set_date)
{
if (xferData == NULL)
return;
Modified: gnucash/trunk/src/gnome-utils/dialog-transfer.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.h 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.h 2012-12-01 22:45:34 UTC (rev 22625)
@@ -136,7 +136,7 @@
* set_date - the date to set
* Return: none
*/
-void gnc_xfer_dialog_set_date(XferDialog *xferData, time_t set_time);
+void gnc_xfer_dialog_set_date(XferDialog *xferData, time64 set_time);
/** Set the exchange rate. If exchange-rate is 0, then do nothing */
void gnc_xfer_dialog_set_exchange_rate(XferDialog *xferData,
Modified: gnucash/trunk/src/gnome-utils/dialog-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-utils.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/dialog-utils.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -40,6 +40,7 @@
#include "gnc-euro.h"
#include "gnc-ui-util.h"
#include "gnc-gconf-utils.h"
+#include <gnc-gdate-utils.h>
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_GUI;
@@ -412,14 +413,9 @@
case GDK_T:
case GDK_t:
- {
/* today */
- GTime gtime;
-
- gtime = time (NULL);
- g_date_set_time_t (&gdate, gtime);
+ gnc_gdate_set_today (&gdate);
break;
- }
default:
return FALSE;
Modified: gnucash/trunk/src/gnome-utils/gnc-cell-renderer-date.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-cell-renderer-date.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-cell-renderer-date.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -91,12 +91,12 @@
/* These two functions are used internally */
-gboolean gcrd_time2dmy ( time_t raw_time, gint *day, gint *month, gint *year);
-static time_t gcrd_dmy2time ( gint day, gint month, gint year);
+gboolean gcrd_time2dmy ( time64 raw_time, gint *day, gint *month, gint *year);
+static time64 gcrd_dmy2time ( gint day, gint month, gint year);
/* These two functions convert string to date to string */
-static gchar * gcrd_time2dmy_string ( time_t raw_time);
-static time_t gcrd_string_dmy2time ( char *date_string);
+static gchar * gcrd_time2dmy_string ( time64 raw_time);
+static time64 gcrd_string_dmy2time ( char *date_string);
static GncCellRendererPopupClass *parent_class;
@@ -181,7 +181,7 @@
date);
//Set calendar to show current date when displayed
- date->time = time(NULL);
+ date->time = gnc_time (NULL);
gtk_widget_show_all (frame);
}
@@ -324,7 +324,7 @@
if (!(g_strcmp0(cell->cell_text, "")))
{
- date->time = time(NULL);
+ date->time = gnc_time (NULL);
gcrd_time2dmy ( date->time, &day, &month, &year);
}
else
@@ -356,10 +356,10 @@
static void
gcrd_today_clicked (GtkWidget *button, GncCellRendererDate *cell)
{
- time_t today;
+ time64 today;
gint year, month, day;
- today = time(NULL);
+ today = gnc_time (NULL);
gcrd_time2dmy ( today, &day, &month, &year);
@@ -409,7 +409,7 @@
guint year;
guint month;
guint day;
- time_t t;
+ time64 t;
gchar *str;
gtk_calendar_get_date (GTK_CALENDAR (cell->calendar),
@@ -450,72 +450,63 @@
}
-/* This function converts a time_t value date to separate entities */
+/* This function converts a time64 value date to separate entities */
gboolean
-gcrd_time2dmy ( time_t raw_time, gint *day, gint *month, gint *year)
+gcrd_time2dmy ( time64 raw_time, gint *day, gint *month, gint *year)
{
struct tm * timeinfo;
- timeinfo = localtime ( &raw_time );
+ timeinfo = gnc_localtime (&raw_time);
*day = timeinfo->tm_mday;
*month = timeinfo->tm_mon + 1;
*year = timeinfo->tm_year + 1900;
-
+ gnc_tm_free (timeinfo);
return TRUE;
}
-/* This function converts separate entities to a time_t value */
-static time_t
+/* This function converts separate entities to a time64 value */
+static time64
gcrd_dmy2time ( gint day, gint month, gint year)
{
- struct tm *when;
+ struct tm when;
- time_t raw_time;
+ memset (&when, 0, sizeof (when));
+ when.tm_year = year - 1900;
+ when.tm_mon = month - 1 ;
+ when.tm_mday = day;
- time(&raw_time);
- when = localtime ( &raw_time );
-
- when->tm_year = year - 1900;
- when->tm_mon = month - 1 ;
- when->tm_mday = day;
-
- return mktime(when);
+ return gnc_mktime (&when);
}
-/* This function converts a time_t value date to a string */
+/* This function converts a time64 value date to a string */
static gchar *
-gcrd_time2dmy_string ( time_t raw_time)
+gcrd_time2dmy_string ( time64 raw_time)
{
return qof_print_date (raw_time);
}
-/* This function converts a string date to a time_t value */
-static time_t
-gcrd_string_dmy2time ( char *date_string)
+/* This function converts a string date to a time64 value */
+static time64
+gcrd_string_dmy2time (char *date_string)
{
- struct tm *when;
gint year = 0, month = 0, day = 0;
- time_t raw_time;
-
if(qof_scan_date (date_string, &day, &month, &year))
{
- time(&raw_time);
- when = localtime ( &raw_time );
+ struct tm when;
+ memset (&when, 0, sizeof (when));
+ when.tm_year = year - 1900;
+ when.tm_mon = month - 1 ;
+ when.tm_mday = day;
- when->tm_year = year - 1900;
- when->tm_mon = month - 1 ;
- when->tm_mday = day;
-
- return mktime(when);
+ return gnc_mktime (&when);
}
else
{
- raw_time = time(NULL);
- return raw_time;
+ return gnc_time (NULL);
}
}
Modified: gnucash/trunk/src/gnome-utils/gnc-cell-renderer-date.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-cell-renderer-date.h 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-cell-renderer-date.h 2012-12-01 22:45:34 UTC (rev 22625)
@@ -33,7 +33,7 @@
#include <glib-object.h>
#include <gtk/gtkwidget.h>
-#include <time.h>
+#include <gnc-date.h>
#include "gnc-cell-renderer-popup.h"
#include "gnc-cell-renderer-popup-entry.h"
@@ -53,7 +53,7 @@
GtkWidget *calendar;
GtkWidget *today_button;
- time_t time;
+ time64 time;
gboolean use_buttons;
GtkWidget *button_box;
Modified: gnucash/trunk/src/gnome-utils/gnc-date-edit.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-date-edit.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-date-edit.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -283,11 +283,6 @@
mtm.tm_year -= 1900;
gnc_tm_set_day_start(&mtm);
- if (mktime (&mtm) == (time_t) - 1)
- {
- gnc_tm_get_today_start (&mtm);
- gnc_date_edit_set_time (gde, mktime (&mtm));
- }
/* Set the calendar. */
gtk_calendar_select_day (GTK_CALENDAR (gde->calendar), 1);
@@ -455,7 +450,7 @@
GtkTreeIter hour_iter, min_iter;
struct tm *tm_returned;
struct tm mtm;
- time_t current_time;
+ time64 current_time;
int i, j;
if (gde->lower_hour > gde->upper_hour)
@@ -463,8 +458,8 @@
model = gtk_combo_box_get_model (GTK_COMBO_BOX(gde->time_combo));
- time (¤t_time);
- tm_returned = localtime_r (¤t_time, &mtm);
+ gnc_time (¤t_time);
+ tm_returned = gnc_localtime_r (¤t_time, &mtm);
g_return_if_fail(tm_returned != NULL);
for (i = gde->lower_hour; i <= gde->upper_hour; i++)
@@ -646,7 +641,7 @@
* to be the one represented by @the_time.
*/
void
-gnc_date_edit_set_time (GNCDateEdit *gde, time_t the_time)
+gnc_date_edit_set_time (GNCDateEdit *gde, time64 the_time)
{
struct tm *tm_returned;
struct tm tm_to_set;
@@ -656,17 +651,10 @@
/* If the_time is invalid, use the last valid time
* seen (or as a last resort, the current date). */
- if (the_time == (time_t) - 1)
- {
- if (gde->initial_time == (time_t) - 1)
- gde->initial_time = gnc_timet_get_today_start();
- the_time = gde->initial_time;
- }
- else
- gde->initial_time = the_time;
+ gde->initial_time = the_time;
- /* Convert time_t to tm. */
- tm_returned = localtime_r (&the_time, &tm_to_set);
+ /* Convert time64 to tm. */
+ tm_returned = gnc_localtime_r (&the_time, &tm_to_set);
g_return_if_fail(tm_returned != NULL);
gnc_date_edit_set_time_tm(gde, &tm_to_set);
@@ -676,14 +664,13 @@
gnc_date_edit_set_gdate (GNCDateEdit *gde, const GDate *date)
{
struct tm mytm;
- time_t t;
+ time64 t;
g_return_if_fail(gde && GNC_IS_DATE_EDIT(gde) &&
date && g_date_valid(date));
g_date_to_struct_tm(date, &mytm);
- t = mktime(&mytm);
- if (t != (time_t)(-1))
- gnc_date_edit_set_time(gde, t);
+ t = gnc_mktime(&mytm);
+ gnc_date_edit_set_time(gde, t);
}
void
@@ -728,7 +715,7 @@
if (!gnc_handle_date_accelerator (event, &tm, string))
return FALSE;
- gnc_date_edit_set_time (gde, mktime (&tm));
+ gnc_date_edit_set_time (gde, gnc_mktime (&tm));
g_signal_emit (G_OBJECT (gde), date_edit_signals [TIME_CHANGED], 0);
return TRUE;
@@ -752,7 +739,7 @@
/* Get the date entered and attempt to use it. */
tm = gnc_date_edit_get_date_internal (gde);
- gnc_date_edit_set_time (gde, mktime (&tm));
+ gnc_date_edit_set_time (gde, gnc_mktime (&tm));
/* Get the date again in case it was invalid the first time. */
tm = gnc_date_edit_get_date_internal (gde);
@@ -900,7 +887,7 @@
* Returns a GNCDateEdit widget.
*/
GtkWidget *
-gnc_date_edit_new (time_t the_time, int show_time, int use_24_format)
+gnc_date_edit_new (time64 the_time, int show_time, int use_24_format)
{
return gnc_date_edit_new_flags
(the_time,
@@ -945,7 +932,7 @@
* Return value: the newly-created date editor widget.
**/
GtkWidget *
-gnc_date_edit_new_flags (time_t the_time, GNCDateEditFlags flags)
+gnc_date_edit_new_flags (time64 the_time, GNCDateEditFlags flags)
{
GNCDateEdit *gde;
@@ -975,11 +962,7 @@
tm.tm_mon--;
- /* Hope the user does not actually mean years early in the A.D. days...
- * This date widget will obviously not work for a history program :-)
- */
- if (tm.tm_year >= 1900)
- tm.tm_year -= 1900;
+ tm.tm_year -= 1900;
if (gde->flags & GNC_DATE_EDIT_SHOW_TIME)
{
@@ -1036,38 +1019,31 @@
*
* Returns the time entered in the GNCDateEdit widget
*/
-time_t
+time64
gnc_date_edit_get_date (GNCDateEdit *gde)
{
struct tm tm;
- time_t retval;
+ time64 retval;
g_return_val_if_fail (gde != NULL, 0);
g_return_val_if_fail (GNC_IS_DATE_EDIT (gde), 0);
tm = gnc_date_edit_get_date_internal (gde);
- retval = mktime (&tm);
- if (retval == (time_t) - 1)
- {
- if (gde->initial_time == (time_t) - 1)
- return gnc_timet_get_today_start ();
- else
- return gde->initial_time;
- }
- return retval;
+ return gnc_mktime (&tm);
}
void
gnc_date_edit_get_gdate (GNCDateEdit *gde, GDate *date)
{
- time_t t;
+ time64 t;
g_return_if_fail (gde && date);
g_return_if_fail (GNC_IS_DATE_EDIT (gde));
t = gnc_date_edit_get_date(gde);
- g_date_set_time_t(date, t);
+ g_date_clear (date, 1);
+ gnc_gdate_set_time64 (date, t);
}
Timespec
@@ -1087,7 +1063,7 @@
* Returns the date entered in the GNCDateEdit widget,
* but with the time adjusted to the end of the day.
*/
-time_t
+time64
gnc_date_edit_get_date_end (GNCDateEdit *gde)
{
struct tm tm;
@@ -1098,14 +1074,7 @@
tm = gnc_date_edit_get_date_internal (gde);
gnc_tm_set_day_end(&tm);
- if (mktime (&tm) == (time_t) - 1)
- {
- if (gde->initial_time == (time_t) - 1)
- return gnc_timet_get_today_end();
- else
- return gnc_timet_get_day_end(gde->initial_time);
- }
- return mktime (&tm);
+ return gnc_mktime (&tm);
}
Timespec
Modified: gnucash/trunk/src/gnome-utils/gnc-date-edit.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-date-edit.h 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-date-edit.h 2012-12-01 22:45:34 UTC (rev 22625)
@@ -70,16 +70,16 @@
GtkWidget *cal_popup;
GtkWidget *calendar;
- time_t initial_time;
+ time64 initial_time;
- int lower_hour;
- int upper_hour;
+ int lower_hour;
+ int upper_hour;
- int flags;
+ int flags;
- int disposed;
+ int disposed;
- gboolean popup_in_progress;
+ gboolean popup_in_progress;
} GNCDateEdit;
typedef struct
@@ -91,7 +91,7 @@
GType gnc_date_edit_get_type (void);
-GtkWidget *gnc_date_edit_new (time_t the_time,
+GtkWidget *gnc_date_edit_new (time64 the_time,
int show_time, int use_24_format);
GtkWidget *gnc_date_edit_new_ts (Timespec the_time,
int show_time, int use_24_format);
@@ -116,20 +116,20 @@
gchar *string1, gchar *string2,
gint int1, gint int2);
-GtkWidget *gnc_date_edit_new_flags (time_t the_time,
+GtkWidget *gnc_date_edit_new_flags (time64 the_time,
GNCDateEditFlags flags);
void gnc_date_edit_set_gdate (GNCDateEdit *gde, const GDate *date);
-void gnc_date_edit_set_time (GNCDateEdit *gde, time_t the_time);
+void gnc_date_edit_set_time (GNCDateEdit *gde, time64 the_time);
void gnc_date_edit_set_time_ts (GNCDateEdit *gde, Timespec the_time);
void gnc_date_edit_set_popup_range (GNCDateEdit *gde,
int low_hour, int up_hour);
void gnc_date_edit_get_gdate (GNCDateEdit *gde, GDate *date);
-time_t gnc_date_edit_get_date (GNCDateEdit *gde);
+time64 gnc_date_edit_get_date (GNCDateEdit *gde);
Timespec gnc_date_edit_get_date_ts (GNCDateEdit *gde);
-time_t gnc_date_edit_get_date_end (GNCDateEdit *gde);
+time64 gnc_date_edit_get_date_end (GNCDateEdit *gde);
Timespec gnc_date_edit_get_date_end_ts (GNCDateEdit *gde);
void gnc_date_edit_set_flags (GNCDateEdit *gde,
Modified: gnucash/trunk/src/gnome-utils/gnc-date-format.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-date-format.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-date-format.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -463,7 +463,7 @@
gboolean enable_year, enable_month, enable_custom, check_modifiers;
static gchar *format, *c;
gchar date_string[MAX_DATE_LEN];
- time_t secs_now;
+ time64 secs_now;
struct tm today;
g_return_if_fail(gdf);
@@ -541,8 +541,8 @@
0, 0, NULL, NULL, gdf);
/* Visual feedback on what the date will look like. */
- secs_now = time(NULL);
- localtime_r(&secs_now, &today);
+ secs_now = gnc_time (NULL);
+ gnc_localtime_r (&secs_now, &today);
qof_strftime(date_string, MAX_DATE_LEN, format, &today);
gtk_label_set_text(GTK_LABEL(priv->sample_label), date_string);
g_free(format);
Modified: gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-dense-cal-store.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -37,6 +37,7 @@
#include "gnc-dense-cal-model.h"
#include "gnc-dense-cal-store.h"
#include "Recurrence.h"
+#include <gnc-gdate-utils.h>
struct _GncDenseCalStore
{
@@ -137,10 +138,10 @@
}
model->num_real_marks = 0;
g_date_clear(&model->start_date, 1);
- g_date_set_time_t(&model->start_date, time(NULL));
+ gnc_gdate_set_today (&model->start_date);
model->end_type = NEVER_END;
g_date_clear(&model->end_date, 1);
- g_date_set_time_t(&model->end_date, time(NULL));
+ gnc_gdate_set_today (&model->end_date);
model->n_occurrences = 0;
return model;
}
Modified: gnucash/trunk/src/gnome-utils/gnc-dense-cal.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-dense-cal.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-dense-cal.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -30,6 +30,7 @@
#include <gtk/gtk.h>
#include <math.h>
#include <stdlib.h>
+#include <gnc-gdate-utils.h>
/**
* Marking ...
@@ -402,11 +403,11 @@
dcal->topPadding = 2;
{
- GDate *now = g_date_new();
- g_date_set_time_t(now, time(NULL));
- _gnc_dense_cal_set_month(dcal, g_date_get_month(now), FALSE);
- _gnc_dense_cal_set_year(dcal, g_date_get_year(now), FALSE);
- g_date_free(now);
+ GDate now;
+ g_date_clear (&now, 1);
+ gnc_gdate_set_today (&now);
+ _gnc_dense_cal_set_month(dcal, g_date_get_month(&now), FALSE);
+ _gnc_dense_cal_set_year(dcal, g_date_get_year(&now), FALSE);
}
recompute_extents(dcal);
Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -569,7 +569,7 @@
gint response;
const char *title = _("Save changes to the file?");
/* This should be the same message as in gnc-main-window.c */
- time_t oldest_change;
+ time64 oldest_change;
gint minutes;
dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
@@ -578,7 +578,7 @@
GTK_BUTTONS_NONE,
"%s", title);
oldest_change = qof_book_get_session_dirty_time(current_book);
- minutes = (time(NULL) - oldest_change) / 60 + 1;
+ minutes = (gnc_time (NULL) - oldest_change) / 60 + 1;
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
ngettext("If you don't save, changes from the past %d minute will be discarded.",
"If you don't save, changes from the past %d minutes will be discarded.",
Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -1134,7 +1134,7 @@
_("If you don't save, changes from the past %d hours and %d minutes will be discarded.");
const gchar *message_days =
_("If you don't save, changes from the past %d days and %d hours will be discarded.");
- time_t oldest_change;
+ time64 oldest_change;
gint minutes, hours, days;
session = gnc_get_current_session();
@@ -1155,7 +1155,7 @@
title,
filename);
oldest_change = qof_book_get_session_dirty_time(book);
- minutes = (time(NULL) - oldest_change) / 60 + 1;
+ minutes = (gnc_time (NULL) - oldest_change) / 60 + 1;
hours = minutes / 60;
minutes = minutes % 60;
days = hours / 24;
Modified: gnucash/trunk/src/gnome-utils/gnc-period-select.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-period-select.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-period-select.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -37,6 +37,7 @@
#include "gnc-date.h"
#include "gnc-gconf-utils.h"
#include "gnc-period-select.h"
+#include <gnc-gdate-utils.h>
enum
{
@@ -138,17 +139,27 @@
gnc_period_sample_update_date_label (GncPeriodSelect *period)
{
GncPeriodSelectPrivate *priv;
- gchar *time_string;
- time_t secs;
+ gchar time_string[MAX_DATE_LENGTH];
+ GDate *date;
+ GncAccountingPeriod which;
g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
if (!priv->date_label)
return;
- secs = gnc_period_select_get_time(GNC_PERIOD_SELECT(period));
- time_string = qof_print_date(secs);
- gtk_label_set_label(GTK_LABEL(priv->date_label), time_string);
- g_free(time_string);
+ which = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->selector));
+ if (which == -1)
+ date = g_date_new_dmy (1, 1, 1970);
+
+ else if (priv->start)
+ date = gnc_accounting_period_start_gdate (which, priv->fy_end,
+ priv->date_base);
+ else
+ date = gnc_accounting_period_end_gdate (which, priv->fy_end,
+ priv->date_base);
+ qof_print_gdate (time_string, MAX_DATE_LENGTH, date);
+ gtk_label_set_label (GTK_LABEL(priv->date_label), time_string);
+ g_date_free (date);
}
@@ -336,7 +347,7 @@
if (show_date)
{
g_date_clear(&date, 1);
- g_date_set_time_t(&date, time (NULL));
+ gnc_gdate_set_time64(&date, gnc_time (NULL));
gnc_period_select_set_date_common(period, &date);
}
else
@@ -732,30 +743,4 @@
priv->date_base);
}
-
-/* Get the currently selected accounting period from a
- * GncPeriodSelect widget. This is used to retrieve the user's
- * selection in the form of an timestamp.
- */
-time_t
-gnc_period_select_get_time (GncPeriodSelect *period)
-{
- GncPeriodSelectPrivate *priv;
- GncAccountingPeriod which;
-
- g_return_val_if_fail(period != NULL, 0);
- g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), 0);
-
- priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
- which = gtk_combo_box_get_active(GTK_COMBO_BOX(priv->selector));
- if (which == -1)
- return 0;
-
- if (priv->start)
- return gnc_accounting_period_start_timet(which, priv->fy_end,
- priv->date_base);
- return gnc_accounting_period_end_timet(which, priv->fy_end,
- priv->date_base);
-}
-
/** @} */
Modified: gnucash/trunk/src/gnome-utils/gnc-period-select.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-period-select.h 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-period-select.h 2012-12-01 22:45:34 UTC (rev 22625)
@@ -182,17 +182,6 @@
* @return The starting/ending time. */
GDate *gnc_period_select_get_date (GncPeriodSelect *period);
-/** Get the currently selected accounting period choice from a
- * GncPeriodSelect widget. This is used to retrieve the user's
- * selection in the form of an timestamp.
- *
- * @param period The selection widget to query.
- *
- * @return The starting/ending time (in seconds since 1970-01-01) of
- * the accounting period selected by the user.
- */
-time_t gnc_period_select_get_time (GncPeriodSelect *period);
-
G_END_DECLS
#endif /* GNC_PERIOD_SELECT_H */
Modified: gnucash/trunk/src/gnome-utils/gnc-recurrence.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-recurrence.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-recurrence.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -138,14 +138,12 @@
{
UIPeriodType pt;
GDate start;
- time_t t;
gboolean show_last, use_wd;
GncRecurrence *gr = GNC_RECURRENCE(d);
pt = get_pt_ui(gr);
- t = gnc_date_edit_get_date(GNC_DATE_EDIT(gr->gde_start));
- g_date_set_time_t(&start, t);
+ gnc_date_edit_get_gdate(GNC_DATE_EDIT(gr->gde_start), &start);
if (pt == GNCR_MONTH)
g_object_set(G_OBJECT(gr->nth_weekday), "visible", TRUE, NULL);
@@ -197,7 +195,7 @@
vb = GTK_VBOX(gtk_builder_get_object (builder, "RecurrenceEntryVBox"));
hb = GTK_HBOX(gtk_builder_get_object (builder, "Startdate_hbox"));
- w = gnc_date_edit_new (time (NULL), FALSE, FALSE);
+ w = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
gr->gde_start = w;
gtk_box_pack_start (GTK_BOX (hb), w, TRUE, TRUE, 0);
gtk_widget_show (w);
@@ -250,9 +248,9 @@
// is there some better way?
{
- time_t t;
- t = gnc_timet_get_day_start_gdate (&start);
- gnc_date_edit_set_time(GNC_DATE_EDIT(gr->gde_start), t);
+ time64 t;
+ t = gnc_time64_get_day_start_gdate (&start);
+ gnc_date_edit_set_time (GNC_DATE_EDIT(gr->gde_start), t);
}
set_pt_ui(gr, pt);
@@ -262,7 +260,6 @@
const Recurrence *
gnc_recurrence_get(GncRecurrence *gr)
{
- time_t t;
guint mult;
UIPeriodType period;
PeriodType pt;
@@ -270,8 +267,7 @@
gboolean use_eom = FALSE, rel;
mult = (guint) gtk_spin_button_get_value_as_int(gr->gsb_mult);
- t = gnc_date_edit_get_date(GNC_DATE_EDIT(gr->gde_start));
- g_date_set_time_t(&start, t);
+ gnc_date_edit_get_gdate(GNC_DATE_EDIT(gr->gde_start), &start);
period = get_pt_ui(gr);
switch (period)
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -578,7 +578,7 @@
gboolean *negative)
{
GncTreeModelAccountPrivate *priv;
- time_t t1, t2;
+ time64 t1, t2;
gnc_numeric b3;
if ( negative )
@@ -615,7 +615,7 @@
Account *account;
gboolean negative; /* used to set "deficit style" also known as red numbers */
gchar *string;
- time_t last_date;
+ time64 last_date;
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model));
g_return_if_fail (iter != NULL);
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -450,7 +450,7 @@
gboolean recurse)
{
Account *acct1, *acct2;
- time_t t1, t2;
+ time64 t1, t2;
gnc_numeric b1, b2;
gint result;
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -859,7 +859,7 @@
gnc_xfer_dialog_set_description (xfer, xaccTransGetDescription (trans));
gnc_xfer_dialog_set_memo (xfer, xaccSplitGetMemo (split));
gnc_xfer_dialog_set_num (xfer, xaccTransGetNum (trans));
- gnc_xfer_dialog_set_date (xfer, timespecToTime_t (xaccTransRetDatePostedTS (trans)));
+ gnc_xfer_dialog_set_date (xfer, timespecToTime64 (xaccTransRetDatePostedTS (trans)));
value = amount;
if (gnc_xfer_dialog_run_exchange_dialog (
@@ -1388,7 +1388,7 @@
//date on new transactions
if (ts.tv_sec == 0)
{
- ts.tv_sec = time (NULL);
+ ts.tv_sec = gnc_time (NULL);
//xaccTransSetDatePostedSecs(trans, ts.tv_sec);
}//if
s = gnc_print_date(ts);
@@ -1960,7 +1960,7 @@
//is a new transaction and set the time to current time to show current
//date on new transactions
- ts.tv_sec = time (NULL);
+ ts.tv_sec = gnc_time (NULL);
xaccTransSetDatePostedSecs(trans, ts.tv_sec);
}
}
@@ -1975,9 +1975,8 @@
const gchar *new_string;
const gchar *current_string;
GDate date;
- struct tm *tm;
char string[1024];
- time_t tt;
+ time64 tt;
//These strings are used to determine if cell data was altered so that keynav works better
g_print("\nremove edit date\n");
@@ -2001,11 +2000,10 @@
g_date_set_parse (&date, new_string);
if (g_date_valid (&date))
{
- time (&tt);
- tm = localtime (&tt);
-
- g_date_to_struct_tm (&date, tm);
- qof_strftime (string, sizeof (string), "%A %d %B %Y", tm);
+ struct tm tm;
+ memset (&tm, 0, sizeof (tm));
+ g_date_to_struct_tm (&date, &tm);
+ qof_strftime (string, sizeof (string), "%A %d %B %Y", &tm);
}
view->help_text = g_strdup (string);
g_signal_emit_by_name (view, "help_signal", NULL);
@@ -2518,19 +2516,16 @@
if(depth == TRANS1)
{
GDate date;
- struct tm *tm;
char string[1024];
- time_t tt;
current_string = g_object_get_data (G_OBJECT (cr), "current-string");
g_date_set_parse (&date, current_string);
if (g_date_valid (&date))
{
- time (&tt);
- tm = localtime (&tt);
-
- g_date_to_struct_tm (&date, tm);
- qof_strftime (string, sizeof (string), "%A %d %B %Y", tm);
+ struct tm tm;
+ memset (&tm, 0, sizeof (tm));
+ g_date_to_struct_tm (&date, &tm);
+ qof_strftime (string, sizeof (string), "%A %d %B %Y", &tm);
}
help = g_strdup (string);
}
Modified: gnucash/trunk/src/gnome-utils/window-main-summarybar.c
===================================================================
--- gnucash/trunk/src/gnome-utils/window-main-summarybar.c 2012-12-01 22:45:23 UTC (rev 22624)
+++ gnucash/trunk/src/gnome-utils/window-main-summarybar.c 2012-12-01 22:45:34 UTC (rev 22625)
@@ -87,8 +87,8 @@
gboolean euro;
gboolean grand_total;
gboolean non_currency;
- time_t start_date;
- time_t end_date;
+ time64 start_date;
+ time64 end_date;
} GNCSummarybarOptions;
/**
@@ -196,11 +196,11 @@
case ACCT_TYPE_PAYABLE:
case ACCT_TYPE_RECEIVABLE:
end_amount = xaccAccountGetBalanceAsOfDate(account, options.end_date);
- timespecFromTime_t(&end_timespec, options.end_date);
+ timespecFromTime64(&end_timespec, options.end_date);
end_amount_default_currency =
xaccAccountConvertBalanceToCurrencyAsOfDate
(account, end_amount, account_currency, options.default_currency,
- timespecToTime_t(timespecCanonicalDayTime(end_timespec)));
+ timespecToTime64(timespecCanonicalDayTime(end_timespec)));
if (!non_currency || options.non_currency)
{
@@ -240,17 +240,17 @@
case ACCT_TYPE_INCOME:
case ACCT_TYPE_EXPENSE:
start_amount = xaccAccountGetBalanceAsOfDate(account, options.start_date);
- timespecFromTime_t(&start_timespec, options.start_date);
+ timespecFromTime64(&start_timespec, options.start_date);
start_amount_default_currency =
xaccAccountConvertBalanceToCurrencyAsOfDate
(account, start_amount, account_currency, options.default_currency,
- timespecToTime_t(timespecCanonicalDayTime(start_timespec)));
+ timespecToTime64(timespecCanonicalDayTime(start_timespec)));
end_amount = xaccAccountGetBalanceAsOfDate(account, options.end_date);
- timespecFromTime_t(&end_timespec, options.end_date);
+ timespecFromTime64(&end_timespec, options.end_date);
end_amount_default_currency =
xaccAccountConvertBalanceToCurrencyAsOfDate
(account, end_amount, account_currency, options.default_currency,
- timespecToTime_t(timespecCanonicalDayTime(end_timespec)));
+ timespecToTime64(timespecCanonicalDayTime(end_timespec)));
if (!non_currency || options.non_currency)
{
More information about the gnucash-changes
mailing list