#include "convert.h" #include #include #include "time.h" using namespace std; void convert_str_chararr(string src, char *dst, int dstlen) { int srcSize = src.size(); int cplen = 0; if(dstlen>=srcSize){ cplen = srcSize; } else { cplen = dstlen; } strlcpy(dst, src.c_str(), cplen); } void convert_isotimestr_time(string timestr, int timezone, LPNET_DVR_TIME time) { struct tm t; strptime(timestr.c_str(), "%Y-%m-%dT%H:%M:%SZ", &t); time_t ts = mktime(&t); ts+=timezone*3600; struct tm ltime; localtime_r(&ts, <ime); time->dwYear = ltime.tm_year + 1900; time->dwMonth = ltime.tm_mon + 1; time->dwDay = ltime.tm_mday; time->dwHour = ltime.tm_hour; time->dwMinute = ltime.tm_min; time->dwSecond = ltime.tm_sec; }