const char * DateRangeDaily::error( void ) const { static Str errStr; errStr.reset(); errStr << getClassName() << ":"; if( good() ) { errStr << "Ok"; } else { if( ! DateRange::good() ) { errStr << ' ' << DateRange::error(); } if( ! (getTimeT() >= 0 ) ) { errStr << " start < 0"; } if( ! (getTimeT() < SecPerDay ) ) { errStr << " start >= 1 day"; } } return( errStr.cstr() ); }
time_t DateRangeDaily::startsIn( const DateRange & dateTwo ) const { time_t secs = 0; if( dateTwo.getSecOfDay() >= getTimeT() && dateTwo.getSecOfDay() <= getTimeT() + dur ) { secs = secIn( dateTwo ); } return( secs ); }
time_t DateRange::startsIn( const DateRange & dateTwo ) const { time_t secs = 0; if( dateTwo.getTimeT() >= getTimeT() && dateTwo.getTimeT() <= (getTimeT() + dur ) ) { secs = secIn( dateTwo ); } return( secs ); }
time_t DateRangeDaily::secIn( const DateRange & dateTwo ) const { return( UnionOfDur( getTimeT(), dur, dateTwo.getSecOfDay(), dateTwo.getDur(), getFrequency() ) ); }
//defaultparse:处理常见时间格式,如时间戳、1980-2-4 am 3:40 、1980-2-4 3:40 am …… bool CDateTime::defaultparse(const char *timestring) { #ifdef __FOR_WIN__ time_t times; if(IsTime_T(timestring,times)) { this->sStamp = times; this->sTm = localtime_r(&sStamp,&sc); return true; }else{ COleDateTime tmptime(sStamp); try { if (tmptime.ParseDateTime(timestring)) { sStamp = getTimeT(tmptime); if (sStamp == -1) { sStamp = time(NULL); return false; } this->sTm = localtime_r(&sStamp,&sc); return true; } } catch(...) { sTm->tm_isdst = 0; sTm->tm_wday = 0; sTm->tm_yday = 0; return false; } } sTm->tm_isdst = 0; sTm->tm_wday = 0; sTm->tm_yday = 0; #endif return false; }
time_t DateRange::secIn( const DateRange & dateTwo ) const { time_t secs = 0; return( UnionOfDur( getTimeT(), dur, dateTwo.getTimeT(), dateTwo.getDur() ) ); return( secs ); }
time_t DateRangeDaily::getStart( void ) const { return( getTimeT() ); }
time_t DateRangeDaily::getSecOfDay( void ) const { return( SecOfDay( getTimeT() ) ); }
bool DateRangeDaily::good( void ) const { return( DateRange::good() && getTimeT() >= 0 && getTimeT() < SecPerDay ); }
bool DateRange::isIn( const DateTime & dateTwo ) const { return( getTimeT() <= dateTwo.getTimeT() && dateTwo.getTimeT() <= (getTimeT() + getDur() ) ); }