diff options
Diffstat (limited to 'core/fxcrt/fx_extension.cpp')
-rw-r--r-- | core/fxcrt/fx_extension.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 8e78e4d789..443e301630 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -12,7 +12,20 @@ #include "third_party/base/compiler_specific.h" -time_t (*time_func)() = []() -> time_t { return time(nullptr); }; +namespace { + +time_t DefaultTimeFunction() { + return time(nullptr); +} + +struct tm* DefaultLocaltimeFunction(const time_t* tp) { + return localtime(tp); +} + +time_t (*g_time_func)() = DefaultTimeFunction; +struct tm* (*g_localtime_func)(const time_t*) = DefaultLocaltimeFunction; + +} // namespace float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { ASSERT(pwsStr); @@ -171,12 +184,20 @@ size_t FXSYS_ToUTF16BE(uint32_t unicode, char* buf) { } void FXSYS_SetTimeFunction(time_t (*func)()) { - time_func = func ? func : []() -> time_t { return time(nullptr); }; + g_time_func = func ? func : DefaultTimeFunction; +} + +void FXSYS_SetLocaltimeFunction(struct tm* (*func)(const time_t*)) { + g_localtime_func = func ? func : DefaultLocaltimeFunction; } time_t FXSYS_time(time_t* tloc) { - time_t ret_val = time_func(); + time_t ret_val = g_time_func(); if (tloc) *tloc = ret_val; return ret_val; } + +struct tm* FXSYS_localtime(const time_t* tp) { + return g_localtime_func(tp); +} |