added time/time_count.cpp
This commit is contained in:
parent
295a4e8678
commit
e5675377b1
@ -76,6 +76,9 @@ target_link_libraries(OSFontList PRIVATE CMUtil)
|
||||
add_executable(DistributionChart2D DistributionChart2D.cpp BitmapFont.cpp BitmapFont.h)
|
||||
cm_example_project("chart" DistributionChart2D)
|
||||
|
||||
add_executable(TimeCount time/time_count.cpp)
|
||||
cm_example_project("time" TimeCount)
|
||||
####################################################################################################
|
||||
add_executable(AndroidDeviceAnalysis android/AndroidDeviceAnalysis/main.cpp
|
||||
android/AndroidDeviceAnalysis/GameRecord.h
|
||||
android/AndroidDeviceAnalysis/GameRecord.cpp
|
||||
|
34
time/time_count.cpp
Normal file
34
time/time_count.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include<hgl/Time.h>
|
||||
#include<hgl/type/DateTime.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<iostream>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace std;
|
||||
|
||||
constexpr const size_t TIME_OUT_FRAC=6; //小数输出位数
|
||||
|
||||
int main(int,char **)
|
||||
{
|
||||
const double cur_time=GetDoubleTime();
|
||||
|
||||
Date d;
|
||||
Time t;
|
||||
|
||||
ToDateTime(d,t,cur_time);
|
||||
|
||||
UTF8String str=UTF8String::floatOf(cur_time,TIME_OUT_FRAC);
|
||||
|
||||
cout<<"cur_time="<<str.c_str()<<endl;
|
||||
cout<<"\tyear="<<d.GetYear()<<" month="<<d.GetMonth()<<" day="<<d.GetDay()<<endl;
|
||||
cout<<"\thour="<<t.GetHour()<<" minute="<<t.GetMinute()<<" second="<<t.GetSecond()<<" micro_second="<<t.GetMicroSecond()<<endl;
|
||||
cout<<endl;
|
||||
|
||||
const double new_time=FromDateTime(d,t);
|
||||
|
||||
str=UTF8String::floatOf(new_time,TIME_OUT_FRAC);
|
||||
cout<<"new_time="<<str.c_str()<<endl;
|
||||
|
||||
cout<<"TimeZone:"<<GetTimeZone()<<endl;
|
||||
return(0);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user