Use gnc_time() instead of time()

This commit is contained in:
Richard Cohen 2023-06-01 16:10:36 +01:00
parent d7c797a46e
commit 6e5c525f77
3 changed files with 8 additions and 7 deletions

View File

@ -1329,19 +1329,19 @@ gnc_time64_get_day_end (time64 time_val)
void
gnc_tm_get_today_start (struct tm *tm)
{
gnc_tm_get_day_start(tm, time(NULL));
gnc_tm_get_day_start(tm, gnc_time(nullptr));
}
void
gnc_tm_get_today_neutral (struct tm *tm)
{
gnc_tm_get_day_neutral(tm, time(NULL));
gnc_tm_get_day_neutral(tm, gnc_time(nullptr));
}
void
gnc_tm_get_today_end (struct tm *tm)
{
gnc_tm_get_day_end(tm, time(NULL));
gnc_tm_get_day_end(tm, gnc_time(nullptr));
}
time64
@ -1349,7 +1349,7 @@ gnc_time64_get_today_start (void)
{
struct tm tm;
gnc_tm_get_day_start(&tm, time(NULL));
gnc_tm_get_day_start(&tm, gnc_time(nullptr));
return gnc_mktime(&tm);
}
@ -1358,7 +1358,7 @@ gnc_time64_get_today_end (void)
{
struct tm tm;
gnc_tm_get_day_end(&tm, time(NULL));
gnc_tm_get_day_end(&tm, gnc_time(nullptr));
return gnc_mktime(&tm);
}

View File

@ -23,6 +23,7 @@
\********************************************************************/
#include "../gnc-datetime.hpp"
#include "../gnc-date.h"
#include <gtest/gtest.h>
/* Backdoor to enable unittests to temporarily override the timezone: */
@ -253,7 +254,7 @@ TEST(gnc_date_operators, test_move_assignment)
TEST(gnc_datetime_constructors, test_default_constructor)
{
GncDateTime atime;
long time_now = time(nullptr);
time64 time_now = gnc_time(nullptr);
EXPECT_EQ(static_cast<time64>(atime), static_cast<time64>(time_now));
}

View File

@ -344,7 +344,7 @@ test_gnc_time (void)
time64 secs1, secs2;
secs1 = gnc_time (&secs2);
g_assert_cmpint (secs1, ==, secs2);
g_assert_cmpint (secs1, ==, time(0));
g_assert_cmpint (secs1, ==, gnc_time(NULL));
}
/* gnc_difftime and gnc_tm_free are just too simple to bother testing. */