cstytime.cpp
来自「特别好玩有启发的东西」· C++ 代码 · 共 55 行
CPP
55 行
#include "cstytime.h"
inline bool
CStyTime::IsHere (const struct tm & t) const
{
if( t.tm_min > 30 ){
return tTime.test (t.tm_hour * 2 + 1);
}
else{
return tTime.test (t.tm_hour * 2);
}
}
inline bool
CStyTime::IsHere (const int hour, const int minute) const
{
if( minute > 30 ){
return tTime.test (hour * 2 + 1);
}
else{
return tTime.test (hour * 2);
}
}
inline void
CStyTime::Clear ()
{
tTime.reset ();
}
inline void
CStyTime::SetHour (const int hour, bool value)
{
tTime.set(hour * 2, value);
}
int CStyTime::SetTimeSeg(std::string strTime)
{
int i;
int len;
len = strTime.length();
if(len != 7*24)
return -1;
std::string::iterator it;
for(it = strTime.begin(),i = 0; it != strTime.end() && i < (7*24); ++it,++i){
if(*it == '0')
tTime.set(i,0);
else if(*it == '1')
tTime.set(i,1);
else return -1;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?