diff options
Diffstat (limited to 'src/misc.cpp')
-rw-r--r-- | src/misc.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/misc.cpp b/src/misc.cpp index d2c05da12..1984477f7 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -785,3 +785,26 @@ size_t Anope::Distance(const Anope::string &s1, const Anope::string &s2) } return costs[s2.length()]; } + +void Anope::UpdateTime() +{ +#ifdef _WIN32 + SYSTEMTIME st; + GetSystemTime(&st); + + CurTime = time(nullptr); + CurTimeNs = st.wMilliseconds; +#elif HAVE_CLOCK_GETTIME + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + + CurTime = ts.tv_sec; + CurTimeNs = ts.tv_nsec; +#else + struct timeval tv; + gettimeofday(&tv, nullptr); + + CurTime = tv.tv_sec; + CurTimeNs = tv.tv_usec * 1000; +#endif +} |