diff --git a/others/src/systime.cpp b/others/src/systime.cpp new file mode 100644 index 0000000..87d3e2e --- /dev/null +++ b/others/src/systime.cpp @@ -0,0 +1,26 @@ +// +// Created by xinyang on 19-7-31. +// +#include + +#if defined(Linux) + +void getsystime(systime &t){ + timeval tv; + gettimeofday(&tv, nullptr); + t.second = tv.tv_sec; + t.millisecond = tv.tv_usec/1000; +} + +#elif defined(Windows) + +void getsystime(systime &t){ + SYSTEMTIME tv; + GetLocalTime(&tv); + t.second = tv.wSecond; + t.millisecond = tv.wMilliseconds; +} + +#else + #error "nonsupport platform." +#endif