2023-04-02 10:44:21 +08:00
|
|
|
#include "../include/convert.h"
|
2023-03-31 18:32:46 +08:00
|
|
|
#include <string>
|
2023-04-02 10:34:59 +08:00
|
|
|
#include <cstring>
|
2023-04-02 10:44:21 +08:00
|
|
|
#include "../include/HCNetSDK.h"
|
2023-03-31 18:32:46 +08:00
|
|
|
#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;
|
|
|
|
}
|
2023-04-02 10:34:59 +08:00
|
|
|
strncpy(dst, src.c_str(), cplen);
|
2023-03-31 18:32:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|