void get_local_time(long sec, char *plocaltime, int len)
{
struct tm t1 = {0};
localtime_r(&sec, &t1);
snprintf(plocaltime, len, "%04d-%02d-%02d %02d:%02d:%02d",
t1.tm_year+1900, t1.tm_mon+1, t1.tm_mday, t1.tm_hour, t1.tm_min, t1.tm_sec);
return ;
}
void get_gm_time(long sec, char *plocaltime, int len)
{
struct tm t1 = {0};
gmtime_r(&sec, &t1);
snprintf(plocaltime, len, "%04d-%02d-%02d %02d:%02d:%02d",
t1.tm_year+1900, t1.tm_mon+1, t1.tm_mday, t1.tm_hour, t1.tm_min, t1.tm_sec);
return ;
}
long get_date_to_sec(char *pTime)
{
if(pTime[0] == '\0') return 0;
struct tm m_tm = {0};
m_tm.tm_isdst = -1;
long ntime = 0;
strptime(pTime, "%Y-%m-%d %H:%M:%S", &m_tm);
ntime = mktime(&m_tm);
return ntime;
}
int mf_random(int min, int max)
{
if (max <= min)
return max;
srand(time(0));
return ((rand() % ((max) - (min))) + (min));
}