From 51bd01e407e0c33dda08e31eea5f9cfde69e47b1 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 24 Apr 2025 22:44:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86DoubleTime=E6=94=B9=E5=90=8D=E4=B8=BAP?= =?UTF-8?q?reciseTime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/Time.h | 10 ++++++---- inc/hgl/type/DateTime.h | 2 +- src/Time/TimeCount.cpp | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/inc/hgl/Time.h b/inc/hgl/Time.h index b5d3e05..a4d5e34 100644 --- a/inc/hgl/Time.h +++ b/inc/hgl/Time.h @@ -5,19 +5,21 @@ namespace hgl //时间 { + using PreciseTime=double; + int GetTimeZone(); ///<返回时区的时差(单位:秒) uint64 GetMilliStartTime(); ///<取得毫秒程序启动时间(单位:1/1000秒) uint64 GetMicroStartTime(); ///<取得微秒程序启动时间(单位:1/1000000秒) - double GetDoubleStartTime(); ///<取得秒程序启动时间(单位:秒) + PreciseTime GetPreciseStartTime(); ///<取得秒程序启动时间(单位:秒) uint64 GetTime(); ///<取得当前时间(单位:1/1000秒) uint64 GetMicroTime(); ///<取得当前时间(单位:1/1000000秒) - double GetDoubleTime(); ///<取得当前时间(单位:秒) + PreciseTime GetPreciseTime(); ///<取得当前时间(单位:秒) - double GetLocalDoubleTime(); ///<取得本地当前时间(单位:秒) + PreciseTime GetLocaPreciseTime(); ///<取得本地当前时间(单位:秒) - void WaitTime(double); ///<等待一定时间(单位:秒) + void WaitTime(const PreciseTime &); ///<等待一定时间(单位:秒) }//namespace hgl #endif//HGL_TIME_INCLUDE diff --git a/inc/hgl/type/DateTime.h b/inc/hgl/type/DateTime.h index 2528c7e..9ec028c 100644 --- a/inc/hgl/type/DateTime.h +++ b/inc/hgl/type/DateTime.h @@ -50,7 +50,7 @@ namespace hgl return ((week*HGL_HOUR_ONE_DAY+hours)*HGL_TIME_ONE_HOUR)+(minutes*HGL_TIME_ONE_MINUTE)+seconds; } -// int GetPastWeekSeconds()const{return int(GetDoubleTime()-GetWeekSeconds());} ///<过去那些年到这周一0点过了多少秒 +// int GetPastWeekSeconds()const{return int(GetPreciseTime()-GetWeekSeconds());} ///<过去那些年到这周一0点过了多少秒 void SetGMT(int go){gmt_off=go;} void SetHour(int); diff --git a/src/Time/TimeCount.cpp b/src/Time/TimeCount.cpp index 07f6695..4886f12 100644 --- a/src/Time/TimeCount.cpp +++ b/src/Time/TimeCount.cpp @@ -35,9 +35,9 @@ namespace hgl * 取得本地当前时间(双精度) * @return 当前时间(单位:秒) */ - double GetLocalDoubleTime() + double GetLocaPreciseTime() { - return GetDoubleTime()+GetTimeZone(); + return GetPreciseTime()+GetTimeZone(); } uint64 GetMilliStartTime() @@ -50,7 +50,7 @@ namespace hgl return program_start_time; } - double GetDoubleStartTime() + double GetPreciseStartTime() { return double(program_start_time)/HGL_MICRO_SEC_PER_SEC; }