From 5212e0da732fe77f5ad11f54b663358d32250554 Mon Sep 17 00:00:00 2001 From: xinyang <895639507@qq.com> Date: Wed, 31 Jul 2019 14:54:40 +0800 Subject: [PATCH] fix bug. --- others/src/systime.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 others/src/systime.cpp 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