Skip to content

Commit

Permalink
Use gnc_time() instead of time()
Browse files Browse the repository at this point in the history
  • Loading branch information
richardcohen committed Jun 6, 2023
1 parent d7c797a commit 6e5c525
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions libgnucash/engine/gnc-date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,27 +1329,27 @@ 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
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);
}

Expand All @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion libgnucash/engine/test/gtest-gnc-datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: */
Expand Down Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion libgnucash/engine/test/test-gnc-date.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 6e5c525

Please sign in to comment.