add GetDaySeconds
This commit is contained in:
parent
f525f6ed71
commit
242ccac983
@ -173,6 +173,12 @@ namespace a8
|
|||||||
return std::string(buff);
|
return std::string(buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time_t GetDaySeconds(time_t time_val, int incdays)
|
||||||
|
{
|
||||||
|
int g_time_zone = 8;
|
||||||
|
return time_t((time_val + g_time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * g_time_zone;
|
||||||
|
}
|
||||||
|
|
||||||
long long MakeInt64(int low32, int high32)
|
long long MakeInt64(int low32, int high32)
|
||||||
{
|
{
|
||||||
return low32 + ((long long)high32 << 32);
|
return low32 + ((long long)high32 << 32);
|
||||||
|
@ -63,7 +63,9 @@ namespace a8
|
|||||||
bool MkDir(const std::string& path);
|
bool MkDir(const std::string& path);
|
||||||
void ForceCreateDir(const std::string& path);
|
void ForceCreateDir(const std::string& path);
|
||||||
std::string GetIpAddress(unsigned long ip_saddr);
|
std::string GetIpAddress(unsigned long ip_saddr);
|
||||||
|
|
||||||
std::string FormatDateTime(time_t time_val);
|
std::string FormatDateTime(time_t time_val);
|
||||||
|
time_t GetDaySeconds(time_t time_val, int incdays = 0);
|
||||||
|
|
||||||
long long MakeInt64(int low32, int high32);
|
long long MakeInt64(int low32, int high32);
|
||||||
int Low32(long long int64_val);
|
int Low32(long long int64_val);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <a8/timer.h>
|
#include <a8/timer.h>
|
||||||
|
|
||||||
|
#if 0
|
||||||
const int g_time_zone = 8; // 默认东八区
|
const int g_time_zone = 8; // 默认东八区
|
||||||
|
|
||||||
static time_t GetDaySeconds(time_t time, int incdays = 0)
|
static time_t GetDaySeconds(time_t time, int incdays = 0)
|
||||||
@ -9,6 +10,8 @@ static time_t GetDaySeconds(time_t time, int incdays = 0)
|
|||||||
return time_t((time + g_time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * g_time_zone;
|
return time_t((time + g_time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * g_time_zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CONFIG_BASE_SMALL 0
|
#define CONFIG_BASE_SMALL 0
|
||||||
#define TVN_BITS (CONFIG_BASE_SMALL ? 4 : 6)
|
#define TVN_BITS (CONFIG_BASE_SMALL ? 4 : 6)
|
||||||
#define TVR_BITS (CONFIG_BASE_SMALL ? 6 : 8)
|
#define TVR_BITS (CONFIG_BASE_SMALL ? 6 : 8)
|
||||||
@ -202,7 +205,7 @@ namespace a8
|
|||||||
timer->milli_seconds = milli_seconds;
|
timer->milli_seconds = milli_seconds;
|
||||||
if (timer->timer_type == 2) {
|
if (timer->timer_type == 2) {
|
||||||
long long tick = a8::XGetTickCount();
|
long long tick = a8::XGetTickCount();
|
||||||
long long today_passed_seconds = time(nullptr) - GetDaySeconds(time(nullptr));
|
long long today_passed_seconds = time(nullptr) - a8::GetDaySeconds(time(nullptr), 0);
|
||||||
timer->expires = (tick - today_passed_seconds * 1000) + milli_seconds;
|
timer->expires = (tick - today_passed_seconds * 1000) + milli_seconds;
|
||||||
if (timer->fixed_timer_execute_times > 0) {
|
if (timer->fixed_timer_execute_times > 0) {
|
||||||
if (timer->expires <= tick) { //已过期
|
if (timer->expires <= tick) { //已过期
|
||||||
|
Loading…
x
Reference in New Issue
Block a user