获取礼拜一的时间戳
UINT64 GetWeekBeginTime()
{
time_t t;
t = time(0);
tm* t_tm = localtime(&t);
t_tm->tm_hour = 0;
t_tm->tm_min = 0;
t_tm->tm_sec = 0;
t_tm->tm_wday = 0; 不生效
t = mktime(t_tm);
return (UINT64)t;
}
源码没有用到这个逻辑
问题 从现网拉到的函数存在问题 直接置 wday为0 在某些编译器下无法生效 所以优化了下逻辑
time_t getWeekFirstTimeStamp()
{
time_t t;
t = time(0);
tm *t_tm = localtime(&t);
t_tm->tm_hour = 0;
t_tm->tm_min = 0;
t_tm->tm_sec = 0;
t_tm->tm_mday = t_tm->tm_mday - t_tm->tm_wday + 1;
t_tm->tm_wday = 0;
t = mktime(t_tm);
return t;
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)