Convert all time_t to time64: libqof

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22617 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls 2012-12-01 22:44:13 +00:00
parent 8fa49c4a21
commit 10b567a79a
10 changed files with 127 additions and 126 deletions

View File

@ -1568,7 +1568,7 @@ gnc_timezone (const struct tm *tm)
void void
timespecFromTime_t( Timespec *ts, time64 t ) timespecFromTime64 ( Timespec *ts, time64 t )
{ {
ts->tv_sec = t; ts->tv_sec = t;
ts->tv_nsec = 0; ts->tv_nsec = 0;
@ -1584,7 +1584,7 @@ timespec_now()
} }
time64 time64
timespecToTime_t (Timespec ts) timespecToTime64 (Timespec ts)
{ {
return ts.tv_sec; return ts.tv_sec;
} }
@ -1646,7 +1646,7 @@ gnc_tm_get_day_end (struct tm *tm, time64 time_val)
} }
time64 time64
gnc_timet_get_day_start (time64 time_val) gnc_time64_get_day_start (time64 time_val)
{ {
struct tm tm; struct tm tm;
time64 new_time; time64 new_time;
@ -1657,7 +1657,7 @@ gnc_timet_get_day_start (time64 time_val)
} }
time64 time64
gnc_timet_get_day_end (time64 time_val) gnc_time64_get_day_end (time64 time_val)
{ {
struct tm tm; struct tm tm;
time64 new_time; time64 new_time;
@ -1683,7 +1683,7 @@ gnc_tm_get_today_end (struct tm *tm)
} }
time64 time64
gnc_timet_get_today_start (void) gnc_time64_get_today_start (void)
{ {
struct tm tm; struct tm tm;
@ -1692,7 +1692,7 @@ gnc_timet_get_today_start (void)
} }
time64 time64
gnc_timet_get_today_end (void) gnc_time64_get_today_end (void)
{ {
struct tm tm; struct tm tm;

View File

@ -323,10 +323,10 @@ Timespec timespecCanonicalDayTime(Timespec t);
Timespec timespec_now (void); Timespec timespec_now (void);
/** Turns a time64 into a Timespec */ /** Turns a time64 into a Timespec */
void timespecFromTime_t( Timespec *ts, time64 t ); void timespecFromTime64 (Timespec *ts, time64 t );
/** Turns a Timespec into a time64 */ /** Turns a Timespec into a time64 */
time64 timespecToTime_t (Timespec ts); time64 timespecToTime64 (Timespec ts);
/** Returns a newly allocated date of the current clock time, taken from /** Returns a newly allocated date of the current clock time, taken from
* time(2). The caller must g_date_free() the object afterwards. */ * time(2). The caller must g_date_free() the object afterwards. */
@ -612,13 +612,13 @@ void gnc_tm_set_day_end (struct tm *tm)
tm->tm_isdst = -1; tm->tm_isdst = -1;
} }
/** 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
* seconds and adjust it to the last second of that day. */ * seconds and adjust it to the last second of that day. */
time64 gnc_timet_get_day_start(time64 time_val); time64 gnc_time64_get_day_start(time64 time_val);
/** 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
* seconds and adjust it to the last second of that day. */ * seconds and adjust it to the last second of that day. */
time64 gnc_timet_get_day_end(time64 time_val); time64 gnc_time64_get_day_end(time64 time_val);
/** Get the numerical last date of the month. (28, 29, 30, 31) */ /** Get the numerical last date of the month. (28, 29, 30, 31) */
int gnc_date_get_last_mday (int month, int year); int gnc_date_get_last_mday (int month, int year);
@ -637,13 +637,13 @@ void gnc_tm_get_today_start(struct tm *tm);
* tm and fills it in with the last second of the today. */ * tm and fills it in with the last second of the today. */
void gnc_tm_get_today_end(struct tm *tm); void gnc_tm_get_today_end(struct tm *tm);
/** The gnc_timet_get_today_start() routine returns a time64 value /** The gnc_time64_get_today_start() routine returns a time64 value
* corresponding to the first second of today. */ * corresponding to the first second of today. */
time64 gnc_timet_get_today_start(void); time64 gnc_time64_get_today_start(void);
/** The gnc_timet_get_today_end() routine returns a time64 value /** The gnc_time64_get_today_end() routine returns a time64 value
* corresponding to the last second of today. */ * corresponding to the last second of today. */
time64 gnc_timet_get_today_end(void); time64 gnc_time64_get_today_end(void);
/** \brief Make a timestamp in YYYYMMDDHHMMSS format. /** \brief Make a timestamp in YYYYMMDDHHMMSS format.
* @return A pointer to the generated string. * @return A pointer to the generated string.

View File

@ -315,7 +315,7 @@ static size_t
init_from_time(void) init_from_time(void)
{ {
size_t total; size_t total;
time_t t_time; time64 time;
#ifdef HAVE_SYS_TIMES_H #ifdef HAVE_SYS_TIMES_H
clock_t clocks; clock_t clocks;
struct tms tms_buf; struct tms tms_buf;
@ -325,9 +325,9 @@ init_from_time(void)
total = 0; total = 0;
t_time = time(NULL); time = gnc_time (NULL);
md5_process_bytes(&t_time, sizeof(t_time), &guid_context); md5_process_bytes(&time, sizeof(time), &guid_context);
total += sizeof(t_time); total += sizeof(time);
#ifdef HAVE_SYS_TIMES_H #ifdef HAVE_SYS_TIMES_H
clocks = times(&tms_buf); clocks = times(&tms_buf);
@ -492,7 +492,7 @@ guid_init(void)
{ {
int n, i; int n, i;
srand((unsigned int) time(NULL)); srand((unsigned int) gnc_time (NULL));
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
{ {

View File

@ -68,7 +68,7 @@
* NULL if an error occured. * NULL if an error occured.
*/ */
KvpFrame * gnc_kvp_bag_add (KvpFrame *kvp_root, const char *path, time_t secs, KvpFrame * gnc_kvp_bag_add (KvpFrame *kvp_root, const char *path, time64 secs,
const char *first_name, ...); const char *first_name, ...);

View File

@ -34,7 +34,7 @@
static KvpFrame * static KvpFrame *
gnc_kvp_array_va (KvpFrame *kvp_root, const char * path, gnc_kvp_array_va (KvpFrame *kvp_root, const char * path,
time_t secs, const char * first_name, va_list ap) time64 secs, const char * first_name, va_list ap)
{ {
KvpFrame *cwd; KvpFrame *cwd;
Timespec ts; Timespec ts;
@ -72,7 +72,7 @@ gnc_kvp_array_va (KvpFrame *kvp_root, const char * path,
KvpFrame * KvpFrame *
gnc_kvp_bag_add (KvpFrame *pwd, const char * path, gnc_kvp_bag_add (KvpFrame *pwd, const char * path,
time_t secs, const char *first_name, ...) time64 secs, const char *first_name, ...)
{ {
KvpFrame *cwd; KvpFrame *cwd;
va_list ap; va_list ap;

View File

@ -184,13 +184,13 @@ void qof_book_mark_session_dirty (QofBook *book)
{ {
/* Set the session dirty upfront, because the callback will check. */ /* Set the session dirty upfront, because the callback will check. */
book->session_dirty = TRUE; book->session_dirty = TRUE;
book->dirty_time = time(NULL); book->dirty_time = gnc_time (NULL);
if (book->dirty_cb) if (book->dirty_cb)
book->dirty_cb(book, TRUE, book->dirty_data); book->dirty_cb(book, TRUE, book->dirty_data);
} }
} }
time_t time64
qof_book_get_session_dirty_time (const QofBook *book) qof_book_get_session_dirty_time (const QofBook *book)
{ {
return book->dirty_time; return book->dirty_time;

View File

@ -81,7 +81,7 @@ struct _QofBook
/* The time when the book was first dirtied. This is a secondary /* The time when the book was first dirtied. This is a secondary
* indicator. It should only be used when session_saved is FALSE. */ * indicator. It should only be used when session_saved is FALSE. */
time_t dirty_time; time64 dirty_time;
/* This callback function is called any time the book dirty flag /* This callback function is called any time the book dirty flag
* changes state. Both clean->dirty and dirty->clean transitions * changes state. Both clean->dirty and dirty->clean transitions
@ -296,7 +296,7 @@ void qof_book_mark_session_saved(QofBook *book);
void qof_book_mark_session_dirty(QofBook *book); void qof_book_mark_session_dirty(QofBook *book);
/** Retrieve the earliest modification time on the book. */ /** Retrieve the earliest modification time on the book. */
time_t qof_book_get_session_dirty_time(const QofBook *book); time64 qof_book_get_session_dirty_time(const QofBook *book);
/** Set the function to call when a book transitions from clean to /** Set the function to call when a book transitions from clean to
* dirty, or vice versa. * dirty, or vice versa.

View File

@ -103,7 +103,7 @@ log4glib_handler(const gchar *log_domain,
{ {
char timestamp_buf[10]; char timestamp_buf[10];
time_t now; time64 now;
struct tm now_tm; struct tm now_tm;
const char *format_24hour = const char *format_24hour =
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
@ -113,8 +113,8 @@ log4glib_handler(const gchar *log_domain,
#endif #endif
; ;
gchar *level_str = qof_log_level_to_string(log_level); gchar *level_str = qof_log_level_to_string(log_level);
now = time(NULL); now = gnc_time (NULL);
localtime_r(&now, &now_tm); gnc_localtime_r (&now, &now_tm);
qof_strftime(timestamp_buf, 9, format_24hour, &now_tm); qof_strftime(timestamp_buf, 9, format_24hour, &now_tm);
fprintf(fout, "* %s %*s <%s> %*s%s%s", fprintf(fout, "* %s %*s <%s> %*s%s%s",

View File

@ -42,7 +42,7 @@ typedef struct
{ {
GDateTime *(*new_local)(gint, gint, gint, gint, gint, gdouble); GDateTime *(*new_local)(gint, gint, gint, gint, gint, gdouble);
GDateTime *(*adjust_for_dst)(GDateTime *, GTimeZone *); GDateTime *(*adjust_for_dst)(GDateTime *, GTimeZone *);
GDateTime *(*new_from_unix_local)(gint64); GDateTime *(*new_from_unix_local)(time64);
GDateTime *(*new_from_timeval_local)(GTimeVal *); GDateTime *(*new_from_timeval_local)(GTimeVal *);
GDateTime *(*new_now_local)(void); GDateTime *(*new_now_local)(void);
GDateTime *(*to_local)(GDateTime *); GDateTime *(*to_local)(GDateTime *);
@ -57,7 +57,7 @@ extern void _gnc_date_time_init (_GncDateTime *);
static void static void
test_gnc_localtime (void) test_gnc_localtime (void)
{ {
gint64 secs[5] = {-43238956734LL, -1123692LL, 432761LL, time64 secs[5] = {-43238956734LL, -1123692LL, 432761LL,
723349832LL, 887326459367LL}; 723349832LL, 887326459367LL};
guint ind; guint ind;
gchar *msg = "gnc_localtime_r: assertion `gdt != NULL' failed"; gchar *msg = "gnc_localtime_r: assertion `gdt != NULL' failed";
@ -103,7 +103,7 @@ test_gnc_localtime (void)
static void static void
test_gnc_gmtime (void) test_gnc_gmtime (void)
{ {
gint64 secs[6] = {-43238956734LL, -1123692LL, 432761LL, time64 secs[6] = {-43238956734LL, -1123692LL, 432761LL,
723349832LL, 887326459367LL, 1175964426LL}; 723349832LL, 887326459367LL, 1175964426LL};
struct tm answers[6] = { struct tm answers[6] = {
#ifdef HAVE_STRUCT_TM_GMTOFF #ifdef HAVE_STRUCT_TM_GMTOFF
@ -162,7 +162,7 @@ static void
test_gnc_mktime (void) test_gnc_mktime (void)
{ {
struct { struct {
gint64 secs; time64 secs;
gint wday; gint wday;
gint yday; gint yday;
} ans[5] = { } ans[5] = {
@ -192,14 +192,14 @@ test_gnc_mktime (void)
for (ind = 0; ind < G_N_ELEMENTS (time); ind++) for (ind = 0; ind < G_N_ELEMENTS (time); ind++)
{ {
gint64 secs = gnc_mktime (&time[ind]); time64 secs = gnc_mktime (&time[ind]);
GDateTime *gdt = gncdt.new_local (time[ind].tm_year + 1900, GDateTime *gdt = gncdt.new_local (time[ind].tm_year + 1900,
time[ind].tm_mon + 1, time[ind].tm_mon + 1,
time[ind].tm_mday, time[ind].tm_mday,
time[ind].tm_hour, time[ind].tm_hour,
time[ind].tm_min, time[ind].tm_min,
(gdouble)time[ind].tm_sec); (gdouble)time[ind].tm_sec);
gint64 offset = g_date_time_get_utc_offset (gdt) / G_TIME_SPAN_SECOND; time64 offset = g_date_time_get_utc_offset (gdt) / G_TIME_SPAN_SECOND;
g_assert_cmpint (secs, ==, ans[ind].secs - offset); g_assert_cmpint (secs, ==, ans[ind].secs - offset);
g_assert_cmpint (time[ind].tm_wday, ==, ans[ind].wday); g_assert_cmpint (time[ind].tm_wday, ==, ans[ind].wday);
g_assert_cmpint (time[ind].tm_yday, ==, ans[ind].yday); g_assert_cmpint (time[ind].tm_yday, ==, ans[ind].yday);
@ -223,7 +223,7 @@ static void
test_gnc_mktime_normalization (void) test_gnc_mktime_normalization (void)
{ {
struct answer { struct answer {
gint64 secs; time64 secs;
gint wday; gint wday;
gint yday; gint yday;
} ans = { 723349832LL, 4, 338 }; } ans = { 723349832LL, 4, 338 };
@ -251,14 +251,14 @@ test_gnc_mktime_normalization (void)
guint ind; guint ind;
for (ind = 0; ind < G_N_ELEMENTS (time); ind++) for (ind = 0; ind < G_N_ELEMENTS (time); ind++)
{ {
gint64 secs = gnc_mktime (&time[ind]); time64 secs = gnc_mktime (&time[ind]);
GDateTime *gdt = gncdt.new_local (time[ind].tm_year + 1900, GDateTime *gdt = gncdt.new_local (time[ind].tm_year + 1900,
time[ind].tm_mon + 1, time[ind].tm_mon + 1,
time[ind].tm_mday, time[ind].tm_mday,
time[ind].tm_hour, time[ind].tm_hour,
time[ind].tm_min, time[ind].tm_min,
(gdouble)time[ind].tm_sec); (gdouble)time[ind].tm_sec);
gint64 offset = g_date_time_get_utc_offset (gdt) / G_TIME_SPAN_SECOND; time64 offset = g_date_time_get_utc_offset (gdt) / G_TIME_SPAN_SECOND;
g_assert_cmpfloat (time[ind].tm_sec, ==, normal_time.tm_sec); g_assert_cmpfloat (time[ind].tm_sec, ==, normal_time.tm_sec);
g_assert_cmpint (time[ind].tm_min, ==, normal_time.tm_min); g_assert_cmpint (time[ind].tm_min, ==, normal_time.tm_min);
g_assert_cmpint (time[ind].tm_hour, ==, normal_time.tm_hour); g_assert_cmpint (time[ind].tm_hour, ==, normal_time.tm_hour);
@ -282,7 +282,7 @@ test_gnc_mktime_normalization (void)
static void static void
test_gnc_ctime (void) test_gnc_ctime (void)
{ {
gint64 secs[5] = {-43238956734LL, -1123692LL, 432761LL, time64 secs[5] = {-43238956734LL, -1123692LL, 432761LL,
723349832LL, 1175964426LL}; 723349832LL, 1175964426LL};
guint ind; guint ind;
for (ind = 0; ind < G_N_ELEMENTS (secs); ind++) for (ind = 0; ind < G_N_ELEMENTS (secs); ind++)
@ -299,7 +299,7 @@ test_gnc_ctime (void)
static void static void
test_gnc_time (void) test_gnc_time (void)
{ {
gint64 secs1, secs2; time64 secs1, secs2;
GDateTime *gdt; GDateTime *gdt;
secs1 = gnc_time (NULL); secs1 = gnc_time (NULL);
secs1 = gnc_time (&secs2); secs1 = gnc_time (&secs2);
@ -480,11 +480,11 @@ test_timespec_equal (void)
{ {
const int sec_per_day = 24 * 3600; const int sec_per_day = 24 * 3600;
const int sec_per_mo = 30 * sec_per_day; const int sec_per_mo = 30 * sec_per_day;
const gint64 sec_per_yr = 365 * sec_per_day; const time64 sec_per_yr = 365 * sec_per_day;
const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892; const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892;
const gint64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day; const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day;
const gint64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day; const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day;
const gint64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day; const time64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day;
Timespec ta = { secs1, nsec1 }; Timespec ta = { secs1, nsec1 };
Timespec tb = { secs2, nsec2 }; Timespec tb = { secs2, nsec2 };
Timespec tc = { secs1, nsec1 }; Timespec tc = { secs1, nsec1 };
@ -508,11 +508,11 @@ test_timespec_cmp (void)
{ {
const int sec_per_day = 24 * 3600; const int sec_per_day = 24 * 3600;
const int sec_per_mo = 30 * sec_per_day; const int sec_per_mo = 30 * sec_per_day;
const gint64 sec_per_yr = 365 * sec_per_day; const time64 sec_per_yr = 365 * sec_per_day;
const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892; const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892;
const gint64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day; const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day;
const gint64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day; const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day;
const gint64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day; const time64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day;
Timespec ta = { secs1, nsec1 }; Timespec ta = { secs1, nsec1 };
Timespec tb = { secs2, nsec2 }; Timespec tb = { secs2, nsec2 };
Timespec tc = { secs1, nsec1 }; Timespec tc = { secs1, nsec1 };
@ -542,11 +542,11 @@ test_timespec_diff (void)
{ {
const gint sec_per_day = 24 * 3600; const gint sec_per_day = 24 * 3600;
const gint sec_per_mo = 30 * sec_per_day; const gint sec_per_mo = 30 * sec_per_day;
const gint64 sec_per_yr = 365 * sec_per_day; const time64 sec_per_yr = 365 * sec_per_day;
const gint64 nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892; const time64 nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892;
const gint64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day; const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day;
const gint64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day; const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day;
const gint64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day; const time64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day;
Timespec ta = { secs1, nsec1 }; Timespec ta = { secs1, nsec1 };
Timespec tb = { secs2, nsec2 }; Timespec tb = { secs2, nsec2 };
Timespec td = { secs3, nsec1 }; Timespec td = { secs3, nsec1 };
@ -556,6 +556,7 @@ test_timespec_diff (void)
Timespec th = { secs1, -nsec3 }; Timespec th = { secs1, -nsec3 };
Timespec tt = timespec_diff (&ta, &ta); Timespec tt = timespec_diff (&ta, &ta);
g_assert_cmpint (tt.tv_sec, ==, 0); g_assert_cmpint (tt.tv_sec, ==, 0);
g_assert_cmpint (tt.tv_nsec, ==, 0); g_assert_cmpint (tt.tv_nsec, ==, 0);
@ -572,7 +573,7 @@ test_timespec_diff (void)
g_assert_cmpint (tt.tv_nsec, ==, 0); g_assert_cmpint (tt.tv_nsec, ==, 0);
tt = timespec_diff (&tf, &th); tt = timespec_diff (&tf, &th);
if (sizeof (time_t) > 4) if (sizeof (glong) > 4)
{ {
glong nsec_diff_norm = 2 * nsec3 - 2 * NANOS_PER_SECOND - NANOS_PER_SECOND; glong nsec_diff_norm = 2 * nsec3 - 2 * NANOS_PER_SECOND - NANOS_PER_SECOND;
g_assert_cmpint (tt.tv_sec, ==, secs2 - secs1 + 2); g_assert_cmpint (tt.tv_sec, ==, secs2 - secs1 + 2);
@ -599,8 +600,8 @@ test_timespec_abs (void)
const int sec_per_mo = 30 * sec_per_day; const int sec_per_mo = 30 * sec_per_day;
const int sec_per_yr = 365 * sec_per_day; const int sec_per_yr = 365 * sec_per_day;
const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892; const int nsec1 = 439652, nsec2 = 132794892, nsec3 = 1132794892;
const gint64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day; const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day;
const gint64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day; const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day;
Timespec ta = { secs1, nsec1 }; Timespec ta = { secs1, nsec1 };
Timespec tf = { secs2 - 1, nsec3 }; /* When normalized, equal to tb */ Timespec tf = { secs2 - 1, nsec3 }; /* When normalized, equal to tb */
Timespec tg = { -secs2, nsec2 }; Timespec tg = { -secs2, nsec2 };
@ -648,11 +649,11 @@ test_timespecCanonicalDayTime (void)
{ {
const int sec_per_day = 24 * 3600; const int sec_per_day = 24 * 3600;
const int sec_per_mo = 30 * sec_per_day; const int sec_per_mo = 30 * sec_per_day;
const gint64 sec_per_yr = 365 * sec_per_day; const time64 sec_per_yr = 365 * sec_per_day;
const gint64 secs = 8 * 3600 + 43 * 60 + 11; const time64 secs = 8 * 3600 + 43 * 60 + 11;
const gint64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day + 8 * 3600 + 43 * 60 + 11; const time64 secs1 = 23 * sec_per_yr + 5 * sec_per_mo + 11 * sec_per_day + 8 * 3600 + 43 * 60 + 11;
const gint64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day + 21 * 3600 + 9 * 60 + 48; const time64 secs2 = 21 * sec_per_yr + 11 * sec_per_mo + 19 * sec_per_day + 21 * 3600 + 9 * 60 + 48;
const gint64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day + 12 * 60; const time64 secs3 = 72 * sec_per_yr + 2 * sec_per_mo + 26 * sec_per_day + 12 * 60;
Timespec t0 = { secs, 0 }; Timespec t0 = { secs, 0 };
Timespec ta = { secs1, 0 }; Timespec ta = { secs1, 0 };
Timespec tb = { secs2, 0 }; Timespec tb = { secs2, 0 };
@ -928,7 +929,7 @@ test_qof_print_date_dmy_buff (void)
#define test_assert_localized_timestring(time, datestr) \ #define test_assert_localized_timestring(time, datestr) \
{ \ { \
gchar t_buff[MAX_DATE_LENGTH]; \ gchar t_buff[MAX_DATE_LENGTH]; \
struct tm *ltime = gnc_localtime ((gint64 *)(&time)); \ struct tm *ltime = gnc_localtime ((time64 *)(&time)); \
strftime (t_buff, sizeof (t_buff), GNC_D_FMT, ltime); \ strftime (t_buff, sizeof (t_buff), GNC_D_FMT, ltime); \
gnc_tm_free (ltime); \ gnc_tm_free (ltime); \
g_assert_cmpstr (datestr, ==, t_buff); \ g_assert_cmpstr (datestr, ==, t_buff); \
@ -937,7 +938,7 @@ test_qof_print_date_dmy_buff (void)
/* qof_print_date_buff /* qof_print_date_buff
size_t size_t
qof_print_date_buff (char * buff, size_t len, time_t t)// C: 3 in 1 Local: 2:0:0 qof_print_date_buff (char * buff, size_t len, time64 t)// C: 3 in 1 Local: 2:0:0
*/ */
static void static void
test_qof_print_date_buff (void) test_qof_print_date_buff (void)
@ -948,9 +949,9 @@ test_qof_print_date_buff (void)
GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0); GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0);
GDateTime *gd3 = gncdt.new_local (2045, 6, 16, 12, 0, 0.0); GDateTime *gd3 = gncdt.new_local (2045, 6, 16, 12, 0, 0.0);
gint64 tm1 = g_date_time_to_unix (gd1); time64 tm1 = g_date_time_to_unix (gd1);
gint64 tm2 = g_date_time_to_unix (gd2); time64 tm2 = g_date_time_to_unix (gd2);
gint64 tm3 = g_date_time_to_unix (gd3); time64 tm3 = g_date_time_to_unix (gd3);
qof_date_format_set (QOF_DATE_FORMAT_UK); qof_date_format_set (QOF_DATE_FORMAT_UK);
memset ((gpointer)buff, 0, sizeof (buff)); memset ((gpointer)buff, 0, sizeof (buff));
@ -1217,7 +1218,7 @@ test_qof_print_gdate (void)
/* qof_print_date /* qof_print_date
char * char *
qof_print_date (time_t t)// C: 29 in 13 Local: 0:0:0 qof_print_date (time64 t)// C: 29 in 13 Local: 0:0:0
*/ */
static void static void
test_qof_print_date (void) test_qof_print_date (void)
@ -1228,9 +1229,9 @@ test_qof_print_date (void)
GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0); GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0);
GDateTime *gd3 = gncdt.new_local (2045, 6, 16, 12, 0, 0.0); GDateTime *gd3 = gncdt.new_local (2045, 6, 16, 12, 0, 0.0);
gint64 tm1 = g_date_time_to_unix (gd1); time64 tm1 = g_date_time_to_unix (gd1);
gint64 tm2 = g_date_time_to_unix (gd2); time64 tm2 = g_date_time_to_unix (gd2);
gint64 tm3 = g_date_time_to_unix (gd3); time64 tm3 = g_date_time_to_unix (gd3);
qof_date_format_set (QOF_DATE_FORMAT_UK); qof_date_format_set (QOF_DATE_FORMAT_UK);
test_assert_qof_print_date (tm1, "23/11/1974"); test_assert_qof_print_date (tm1, "23/11/1974");
@ -1936,12 +1937,12 @@ gnc_timezone (const struct tm *tm)// C: 5 in 2 Local: 2:0:0
test_gnc_timezone (void) test_gnc_timezone (void)
{ {
}*/ }*/
/* timespecFromTime_t /* timespecFromtime64
void void
timespecFromTime_t( Timespec *ts, time_t t )// C: 22 in 11 Local: 0:0:0 timespecFromtime64( Timespec *ts, time64 t )// C: 22 in 11 Local: 0:0:0
*/ */
/* static void /* static void
test_timespecFromTime_t (void) test_timespecFromtime64 (void)
{ {
}*/ }*/
/* timespec_now /* timespec_now
@ -1952,12 +1953,12 @@ timespec_now()// C: 2 in 2 Local: 0:0:0
test_timespec_now (void) test_timespec_now (void)
{ {
}*/ }*/
/* timespecToTime_t /* timespecTotime64
time_t time64
timespecToTime_t (Timespec ts)// C: 10 in 6 Local: 1:0:0 timespecTotime64 (Timespec ts)// C: 10 in 6 Local: 1:0:0
*/ */
/* static void /* static void
test_timespecToTime_t (void) test_timespecTotime64 (void)
{ {
}*/ }*/
/* timespec_to_gdate /* timespec_to_gdate
@ -2093,7 +2094,7 @@ test_gdate_to_timespec (void)
} }
/* gnc_tm_get_day_start /* gnc_tm_get_day_start
static void static void
gnc_tm_get_day_start (struct tm *tm, time_t time_val)// Local: 3:0:0 gnc_tm_get_day_start (struct tm *tm, time64 time_val)// Local: 3:0:0
*/ */
/* static void /* static void
test_gnc_tm_get_day_start (void) test_gnc_tm_get_day_start (void)
@ -2101,18 +2102,18 @@ test_gnc_tm_get_day_start (void)
}*/ }*/
/* gnc_tm_get_day_end /* gnc_tm_get_day_end
static void static void
gnc_tm_get_day_end (struct tm *tm, time_t time_val)// Local: 3:0:0 gnc_tm_get_day_end (struct tm *tm, time64 time_val)// Local: 3:0:0
*/ */
/* static void /* static void
test_gnc_tm_get_day_end (void) test_gnc_tm_get_day_end (void)
{ {
}*/ }*/
/* gnc_timet_get_day_start /* gnc_time64_get_day_start
time_t time64
gnc_timet_get_day_start (time_t time_val)// C: 8 in 7 Local: 0:0:0 gnc_time64_get_day_start (time64 time_val)// C: 8 in 7 Local: 0:0:0
*/ */
static void static void
test_gnc_timet_get_day_start (void) test_gnc_time64_get_day_start (void)
{ {
GTimeZone *zulu = g_time_zone_new ("Z"); GTimeZone *zulu = g_time_zone_new ("Z");
GTimeZone *tz05 = g_time_zone_new ("-05"); GTimeZone *tz05 = g_time_zone_new ("-05");
@ -2126,14 +2127,14 @@ test_gnc_timet_get_day_start (void)
GDateTime *gdt_local, *gdt_day_begin; GDateTime *gdt_local, *gdt_day_begin;
gint day, mon, yr; gint day, mon, yr;
gint64 time, t_time, r_time; time64 time, t_time, r_time;
gdt_local = gncdt.to_local (gdt0); gdt_local = gncdt.to_local (gdt0);
time = g_date_time_to_unix (gdt0); time = g_date_time_to_unix (gdt0);
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0); gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0);
t_time = g_date_time_to_unix (gdt_day_begin); t_time = g_date_time_to_unix (gdt_day_begin);
r_time = gnc_timet_get_day_start (time); r_time = gnc_time64_get_day_start (time);
/* This will work in the half of the world where localtime is later than UTC */ /* This will work in the half of the world where localtime is later than UTC */
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
@ -2142,7 +2143,7 @@ test_gnc_timet_get_day_start (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0); gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0);
t_time = g_date_time_to_unix (gdt_day_begin); t_time = g_date_time_to_unix (gdt_day_begin);
r_time = gnc_timet_get_day_start (time); r_time = gnc_time64_get_day_start (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt2); gdt_local = gncdt.to_local (gdt2);
@ -2150,7 +2151,7 @@ test_gnc_timet_get_day_start (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0); gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0);
t_time = g_date_time_to_unix (gdt_day_begin); t_time = g_date_time_to_unix (gdt_day_begin);
r_time = gnc_timet_get_day_start (time); r_time = gnc_time64_get_day_start (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt3); gdt_local = gncdt.to_local (gdt3);
@ -2158,7 +2159,7 @@ test_gnc_timet_get_day_start (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0); gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0);
t_time = g_date_time_to_unix (gdt_day_begin); t_time = g_date_time_to_unix (gdt_day_begin);
r_time = gnc_timet_get_day_start (time); r_time = gnc_time64_get_day_start (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt4); gdt_local = gncdt.to_local (gdt4);
@ -2166,7 +2167,7 @@ test_gnc_timet_get_day_start (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0); gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0);
t_time = g_date_time_to_unix (gdt_day_begin); t_time = g_date_time_to_unix (gdt_day_begin);
r_time = gnc_timet_get_day_start (time); r_time = gnc_time64_get_day_start (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt5); gdt_local = gncdt.to_local (gdt5);
@ -2174,7 +2175,7 @@ test_gnc_timet_get_day_start (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0); gdt_day_begin = gncdt.new_local (yr, mon, day, 0, 0, 0);
t_time = g_date_time_to_unix (gdt_day_begin); t_time = g_date_time_to_unix (gdt_day_begin);
r_time = gnc_timet_get_day_start (time); r_time = gnc_time64_get_day_start (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
g_date_time_unref (gdt0); g_date_time_unref (gdt0);
@ -2187,12 +2188,12 @@ test_gnc_timet_get_day_start (void)
g_time_zone_unref (tz05); g_time_zone_unref (tz05);
g_time_zone_unref (tz0840); g_time_zone_unref (tz0840);
} }
/* gnc_timet_get_day_end /* gnc_time64_get_day_end
time_t time64
gnc_timet_get_day_end (time_t time_val)// C: 12 in 8 Local: 0:0:0 gnc_time64_get_day_end (time64 time_val)// C: 12 in 8 Local: 0:0:0
*/ */
static void static void
test_gnc_timet_get_day_end (void) test_gnc_time64_get_day_end (void)
{ {
GTimeZone *zulu = g_time_zone_new ("Z"); GTimeZone *zulu = g_time_zone_new ("Z");
GTimeZone *tz05 = g_time_zone_new ("-05"); GTimeZone *tz05 = g_time_zone_new ("-05");
@ -2206,14 +2207,14 @@ test_gnc_timet_get_day_end (void)
GDateTime *gdt_local, *gdt_day_end; GDateTime *gdt_local, *gdt_day_end;
gint day, mon, yr; gint day, mon, yr;
gint64 time, t_time, r_time; time64 time, t_time, r_time;
gdt_local = gncdt.to_local (gdt0); gdt_local = gncdt.to_local (gdt0);
time = g_date_time_to_unix (gdt0); time = g_date_time_to_unix (gdt0);
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59); gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59);
t_time = g_date_time_to_unix (gdt_day_end); t_time = g_date_time_to_unix (gdt_day_end);
r_time = gnc_timet_get_day_end (time); r_time = gnc_time64_get_day_end (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt1); gdt_local = gncdt.to_local (gdt1);
@ -2221,7 +2222,7 @@ test_gnc_timet_get_day_end (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59); gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59);
t_time = g_date_time_to_unix (gdt_day_end); t_time = g_date_time_to_unix (gdt_day_end);
r_time = gnc_timet_get_day_end (time); r_time = gnc_time64_get_day_end (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt2); gdt_local = gncdt.to_local (gdt2);
@ -2229,7 +2230,7 @@ test_gnc_timet_get_day_end (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59); gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59);
t_time = g_date_time_to_unix (gdt_day_end); t_time = g_date_time_to_unix (gdt_day_end);
r_time = gnc_timet_get_day_end (time); r_time = gnc_time64_get_day_end (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt3); gdt_local = gncdt.to_local (gdt3);
@ -2237,7 +2238,7 @@ test_gnc_timet_get_day_end (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59); gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59);
t_time = g_date_time_to_unix (gdt_day_end); t_time = g_date_time_to_unix (gdt_day_end);
r_time = gnc_timet_get_day_end (time); r_time = gnc_time64_get_day_end (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt4); gdt_local = gncdt.to_local (gdt4);
@ -2245,7 +2246,7 @@ test_gnc_timet_get_day_end (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59); gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59);
t_time = g_date_time_to_unix (gdt_day_end); t_time = g_date_time_to_unix (gdt_day_end);
r_time = gnc_timet_get_day_end (time); r_time = gnc_time64_get_day_end (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
gdt_local = gncdt.to_local (gdt5); gdt_local = gncdt.to_local (gdt5);
@ -2253,7 +2254,7 @@ test_gnc_timet_get_day_end (void)
g_date_time_get_ymd (gdt_local, &yr, &mon, &day); g_date_time_get_ymd (gdt_local, &yr, &mon, &day);
gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59); gdt_day_end = gncdt.new_local (yr, mon, day, 23, 59, 59);
t_time = g_date_time_to_unix (gdt_day_end); t_time = g_date_time_to_unix (gdt_day_end);
r_time = gnc_timet_get_day_end (time); r_time = gnc_time64_get_day_end (time);
g_assert_cmpint (t_time, ==, r_time); g_assert_cmpint (t_time, ==, r_time);
g_date_time_unref (gdt0); g_date_time_unref (gdt0);
@ -2279,20 +2280,20 @@ test_gnc_tm_get_today_start (void)
void void
gnc_tm_get_today_end (struct tm *tm)// Local: 0:0:0 gnc_tm_get_today_end (struct tm *tm)// Local: 0:0:0
*/ */
/* gnc_timet_get_today_start /* gnc_time64_get_today_start
time_t time64
gnc_timet_get_today_start (void)// C: 7 in 4 Local: 0:0:0 gnc_time64_get_today_start (void)// C: 7 in 4 Local: 0:0:0
*/ */
/* static void /* static void
test_gnc_timet_get_today_start (void) test_gnc_time64_get_today_start (void)
{ {
}*/ }*/
/* gnc_timet_get_today_end /* gnc_time64_get_today_end
time_t time64
gnc_timet_get_today_end (void)// C: 8 in 5 Local: 0:0:0 gnc_time64_get_today_end (void)// C: 8 in 5 Local: 0:0:0
*/ */
/* static void /* static void
test_gnc_timet_get_today_end (void) test_gnc_time64_get_today_end (void)
{ {
}*/ }*/
/* gnc_dow_abbrev /* gnc_dow_abbrev
@ -2373,18 +2374,18 @@ test_suite_gnc_date (void)
GNC_TEST_ADD_FUNC (suitename, "gnc dmy2timespec", test_gnc_dmy2timespec); GNC_TEST_ADD_FUNC (suitename, "gnc dmy2timespec", test_gnc_dmy2timespec);
GNC_TEST_ADD_FUNC (suitename, "gnc dmy2timespec end", test_gnc_dmy2timespec_end); GNC_TEST_ADD_FUNC (suitename, "gnc dmy2timespec end", test_gnc_dmy2timespec_end);
// GNC_TEST_ADD_FUNC (suitename, "gnc timezone", test_gnc_timezone); // GNC_TEST_ADD_FUNC (suitename, "gnc timezone", test_gnc_timezone);
// GNC_TEST_ADD_FUNC (suitename, "timespecFromTime t", test_timespecFromTime_t); // GNC_TEST_ADD_FUNC (suitename, "timespecFromTime t", test_timespecFromtime64);
// GNC_TEST_ADD_FUNC (suitename, "timespec now", test_timespec_now); // GNC_TEST_ADD_FUNC (suitename, "timespec now", test_timespec_now);
// GNC_TEST_ADD_FUNC (suitename, "timespecToTime t", test_timespecToTime_t); // GNC_TEST_ADD_FUNC (suitename, "timespecToTime t", test_timespecTotime64);
GNC_TEST_ADD_FUNC (suitename, "timespec to gdate", test_timespec_to_gdate); GNC_TEST_ADD_FUNC (suitename, "timespec to gdate", test_timespec_to_gdate);
GNC_TEST_ADD_FUNC (suitename, "gdate to timespec", test_gdate_to_timespec); GNC_TEST_ADD_FUNC (suitename, "gdate to timespec", test_gdate_to_timespec);
// GNC_TEST_ADD_FUNC (suitename, "gnc tm get day start", test_gnc_tm_get_day_start); // GNC_TEST_ADD_FUNC (suitename, "gnc tm get day start", test_gnc_tm_get_day_start);
// GNC_TEST_ADD_FUNC (suitename, "gnc tm get day end", test_gnc_tm_get_day_end); // GNC_TEST_ADD_FUNC (suitename, "gnc tm get day end", test_gnc_tm_get_day_end);
GNC_TEST_ADD_FUNC (suitename, "gnc timet get day start", test_gnc_timet_get_day_start); GNC_TEST_ADD_FUNC (suitename, "gnc time64 get day start", test_gnc_time64_get_day_start);
GNC_TEST_ADD_FUNC (suitename, "gnc timet get day end", test_gnc_timet_get_day_end); GNC_TEST_ADD_FUNC (suitename, "gnc time64 get day end", test_gnc_time64_get_day_end);
// GNC_TEST_ADD_FUNC (suitename, "gnc tm get today start", test_gnc_tm_get_today_start); // GNC_TEST_ADD_FUNC (suitename, "gnc tm get today start", test_gnc_tm_get_today_start);
// GNC_TEST_ADD_FUNC (suitename, "gnc timet get today start", test_gnc_timet_get_today_start); // GNC_TEST_ADD_FUNC (suitename, "gnc timet get today start", test_gnc_time64_get_today_start);
// GNC_TEST_ADD_FUNC (suitename, "gnc timet get today end", test_gnc_timet_get_today_end); // GNC_TEST_ADD_FUNC (suitename, "gnc timet get today end", test_gnc_time64_get_today_end);
// GNC_TEST_ADD_FUNC (suitename, "gnc dow abbrev", test_gnc_dow_abbrev); // GNC_TEST_ADD_FUNC (suitename, "gnc dow abbrev", test_gnc_dow_abbrev);
// GNC_TEST_ADD_FUNC (suitename, "timespec boxed copy func", test_timespec_boxed_copy_func); // GNC_TEST_ADD_FUNC (suitename, "timespec boxed copy func", test_timespec_boxed_copy_func);
// GNC_TEST_ADD_FUNC (suitename, "timespec boxed free func", test_timespec_boxed_free_func); // GNC_TEST_ADD_FUNC (suitename, "timespec boxed free func", test_timespec_boxed_free_func);

View File

@ -213,7 +213,7 @@ test_book_session_not_saved( Fixture *fixture, gconstpointer pData )
static void static void
test_book_mark_session_saved( Fixture *fixture, gconstpointer pData ) test_book_mark_session_saved( Fixture *fixture, gconstpointer pData )
{ {
time_t dirty_time, clean_time; time64 dirty_time, clean_time;
qof_book_mark_session_dirty( fixture-> book ); qof_book_mark_session_dirty( fixture-> book );
g_assert( qof_book_session_not_saved( fixture->book ) ); g_assert( qof_book_session_not_saved( fixture->book ) );
@ -423,7 +423,7 @@ static void
test_book_mark_session_dirty( Fixture *fixture, gconstpointer pData ) test_book_mark_session_dirty( Fixture *fixture, gconstpointer pData )
{ {
QofBook *_empty = NULL; QofBook *_empty = NULL;
time_t before, after; time64 before, after;
guint param = (guint) g_test_rand_int(); guint param = (guint) g_test_rand_int();
g_test_message( "Testing when book is NULL" ); g_test_message( "Testing when book is NULL" );
@ -434,9 +434,9 @@ test_book_mark_session_dirty( Fixture *fixture, gconstpointer pData )
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0);
g_assert( fixture->book->dirty_cb == NULL ); g_assert( fixture->book->dirty_cb == NULL );
g_assert( qof_book_session_not_saved( fixture->book ) == FALSE ); g_assert( qof_book_session_not_saved( fixture->book ) == FALSE );
before = time( NULL ); before = gnc_time (NULL);
qof_book_mark_session_dirty( fixture->book ); qof_book_mark_session_dirty( fixture->book );
after = time( NULL ); after = gnc_time (NULL);
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before);
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after);
g_assert( qof_book_session_not_saved( fixture->book ) == TRUE ); g_assert( qof_book_session_not_saved( fixture->book ) == TRUE );
@ -451,9 +451,9 @@ test_book_mark_session_dirty( Fixture *fixture, gconstpointer pData )
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0);
g_assert( qof_book_session_not_saved( fixture->book ) == FALSE ); g_assert( qof_book_session_not_saved( fixture->book ) == FALSE );
/* run FUT */ /* run FUT */
before = time( NULL ); before = gnc_time (NULL);
qof_book_mark_session_dirty( fixture->book ); qof_book_mark_session_dirty( fixture->book );
after = time( NULL ); after = gnc_time (NULL);
/* test output */ /* test output */
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before);
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after);
@ -472,16 +472,16 @@ test_book_mark_session_dirty( Fixture *fixture, gconstpointer pData )
static void static void
test_book_get_session_dirty_time( Fixture *fixture, gconstpointer pData ) test_book_get_session_dirty_time( Fixture *fixture, gconstpointer pData )
{ {
time_t before, after; time64 before, after;
g_test_message( "Testing time on saved book = 0" ); g_test_message( "Testing time on saved book = 0" );
g_assert( qof_book_session_not_saved( fixture->book ) == FALSE ); g_assert( qof_book_session_not_saved( fixture->book ) == FALSE );
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), == , 0);
g_test_message( "Testing time on dirty book is correct" ); g_test_message( "Testing time on dirty book is correct" );
before = time( NULL ); before = gnc_time (NULL);
qof_book_mark_session_dirty( fixture->book ); qof_book_mark_session_dirty( fixture->book );
after = time( NULL ); after = gnc_time (NULL);
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), >= , before);
g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after); g_assert_cmpint( qof_book_get_session_dirty_time( fixture->book ), <= , after);