diff options
Diffstat (limited to 'core/fxcrt')
-rw-r--r-- | core/fxcrt/fx_extension.cpp | 14 | ||||
-rw-r--r-- | core/fxcrt/fx_extension.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index c754a85508..8320b45db4 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -11,6 +11,9 @@ #include <limits> #include "third_party/base/compiler_specific.h" +#include "third_party/base/ptr_util.h" + +time_t (*time_func)() = []() -> time_t { return time(nullptr); }; float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { ASSERT(pwsStr); @@ -167,3 +170,14 @@ size_t FXSYS_ToUTF16BE(uint32_t unicode, char* buf) { FXSYS_IntToFourHexChars(0xDC00 + unicode % 0x400, buf + 4); return 8; } + +void FXSYS_SetTimeFunction(time_t (*func)()) { + time_func = func ? func : []() -> time_t { return time(nullptr); }; +} + +time_t FXSYS_time(time_t* tloc) { + time_t ret_val = time_func(); + if (tloc) + *tloc = ret_val; + return ret_val; +} diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h index dcdd64e1fc..6a49ee1116 100644 --- a/core/fxcrt/fx_extension.h +++ b/core/fxcrt/fx_extension.h @@ -109,4 +109,7 @@ bool FXSYS_SafeLT(const T& lhs, const T& rhs) { return lhs < rhs; } +void FXSYS_SetTimeFunction(time_t (*func)()); +time_t FXSYS_time(time_t* tloc); + #endif // CORE_FXCRT_FX_EXTENSION_H_ |