time_t StringToTime_t( const std::string& strTime ) { struct tm tm1; time_t time1; int i = sscanf_s(strTime.c_str(), "%d/%d/%d %d:%d:%d", &(tm1.tm_year), &(tm1.tm_mon), &(tm1.tm_mday), &(tm1.tm_hour), &(tm1.tm_min), &(tm1.tm_sec), &(tm1.tm_wday), &(tm1.tm_yday)); tm1.tm_year -= 1900; tm1.tm_mon --; tm1.tm_isdst=-1; time1 = mktime(&tm1); return time1; } std::string Time_tToString( time_t& tTime ) { //struct tm *p; //p = localtime(&tTime); tm temptm ; int iRet = localtime_s(&temptm, &tTime); temptm.tm_year = temptm.tm_year + 1900; temptm.tm_mon = temptm.tm_mon + 1; char aTime[50] = {'\0'}; sprintf_s(aTime, "%04d/%02d/%02d %02d:%02d:%02d", temptm.tm_year, temptm.tm_mon, temptm.tm_mday,temptm.tm_hour,temptm.tm_min,temptm.tm_sec); return aTime; } UINT32 IsValidUserName( std::string& username ) { if(!username.empty()) { for(auto& iter:username ) { if( (iter>='0' && iter<='9') || (iter>='a' && iter<='z') || (iter>='A' && iter<='Z') || '_' == iter ) { continue; } return V_ERR; } } else { return V_ERR; } return V_OK; } |
|