Skip to content

Commit c73c1ff

Browse files
committed
refactor: handle min time in clock
1 parent 6eb1191 commit c73c1ff

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/time/Clock.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
namespace ECFMP::Time {
44

5-
std::chrono::system_clock::time_point testNow = std::chrono::system_clock::time_point::min();
5+
auto DefaultTime() -> std::chrono::system_clock::time_point
6+
{
7+
return (std::chrono::system_clock::time_point::min)();
8+
}
9+
10+
std::chrono::system_clock::time_point testNow = DefaultTime();
611

712
auto TimeNow() -> std::chrono::system_clock::time_point
813
{
9-
if (testNow != std::chrono::system_clock::time_point::min()) {
10-
return testNow;
11-
}
12-
13-
return std::chrono::system_clock::now();
14+
return testNow != DefaultTime() ? testNow : std::chrono::system_clock::now();
1415
}
1516

1617
void SetTestNow(const std::chrono::system_clock::time_point& now)
@@ -20,6 +21,6 @@ namespace ECFMP::Time {
2021

2122
void UnsetTestNow()
2223
{
23-
testNow = std::chrono::system_clock::time_point::min();
24+
testNow = DefaultTime();
2425
}
2526
}// namespace ECFMP::Time

0 commit comments

Comments
 (0)