From c7f4421c618ceb89c0b65a833aad2e7f4f12bb0b Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 27 Aug 2019 20:28:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BToDateTime=E5=9C=A8=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=97=B6=E9=97=B4=E4=B8=BA0=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Win/DateTime.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Win/DateTime.cpp b/src/Win/DateTime.cpp index eba071d..0249d73 100644 --- a/src/Win/DateTime.cpp +++ b/src/Win/DateTime.cpp @@ -80,10 +80,10 @@ namespace hgl SystemTimeToTzSpecificLocalTime(&time_zone, &st, &local_time); - hours = local_time.wHour; - minutes = local_time.wMinute; - seconds = local_time.wSecond; - micro_seconds = local_time.wMilliseconds * 1000; + hours = local_time.wHour; + minutes = local_time.wMinute; + seconds = local_time.wSecond; + micro_seconds = local_time.wMilliseconds * 1000; week_day = local_time.wDayOfWeek; SystemTimeToMicroTime(<64, &local_time); @@ -118,9 +118,17 @@ namespace hgl FILETIME ft,local_ft; SYSTEMTIME st; - MicroTimeToFileTime(&ft, cur_time*HGL_MICRO_SEC_PER_SEC); + if(cur_time<=0) + { + GetLocalTime(&st); + SystemTimeToFileTime(&st,&ft); + } + else + { + MicroTimeToFileTime(&ft, cur_time*HGL_MICRO_SEC_PER_SEC); + FileTimeToSystemTime(&ft, &st); + } - FileTimeToSystemTime(&ft, &st); FileTimeToLocalFileTime(&ft, &local_ft); d.Set(st.wYear, st.wMonth, st.wDay, st.wDayOfWeek);