You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.0 KiB
C++

#include "StdAfx.h"
#include "ValStrTime.h"
CValStrTime::CValStrTime(void)
{
m_TimeType = _TIME_HOUR_24;
m_ValStrType = _STR_TIME;
}
CValStrTime::~CValStrTime(void)
{
}
CString CValStrTime::GetTypeStr()
{
return "Time";
}
CString CValStrTime::GetStr()
{
//获取当前系统时间
CTime tm; tm=CTime::GetCurrentTime();
int time;
CString str;
switch(m_TimeType)
{
case _TIME_HOUR_24:
time = tm.GetHour();
str.Format("%ld",time);
break;
case _TIME_HOUR_12:
time = tm.GetHour();
str.Format("%ld",time%12);
break;
case _TIME_MINUTE:
time = tm.GetMinute();
str.Format("%ld",time);
break;
case _TIME_SECOND:
time = tm.GetSecond();
str.Format("%ld",time);
break;
case _TIME_AM_OR_PM_1:
time = tm.GetHour();
if(time>=12)
{
str = "PM";
}
else
{
str = "AM";
}
break;
case _TIME_AM_OR_PM_2:
time = tm.GetHour();
if(time>=12)
{
str = "pm";
}
else
{
str = "am";
}
break;
default:
break;
}
//左边补0
AddLeftZreo(str);
return str;
}
CString CValStrTime::GetTimeTypeStr()
{
CString str;
switch(m_TimeType)
{
case _TIME_HOUR_24:
str = "小时- 24";
break;
case _TIME_HOUR_12:
str = "小时- 12";
break;
case _TIME_MINUTE:
str = "分钟";
break;
case _TIME_SECOND:
str = "";
break;
case _TIME_AM_OR_PM_1:
str = "时间段(AM,PM)";
break;
case _TIME_AM_OR_PM_2:
str = "时间段(am,pm)";
break;
default:
break;
}
return str;
}