forked from Ocean/datum_gateway
Use localtime_r in get_midnight_timestamp()
It's thread-safe and it's 4x faster too
This commit is contained in:
parent
62d92d04fb
commit
c4900b4afd
@ -231,12 +231,13 @@ int datum_logger_queue_msg(const char *func, int level, const char *format, ...)
|
|||||||
|
|
||||||
time_t get_midnight_timestamp(void) {
|
time_t get_midnight_timestamp(void) {
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm *tm_now = localtime(&now);
|
struct tm tm_now;
|
||||||
tm_now->tm_hour = 0;
|
localtime_r(&now, &tm_now);
|
||||||
tm_now->tm_min = 0;
|
tm_now.tm_hour = 0;
|
||||||
tm_now->tm_sec = 0;
|
tm_now.tm_min = 0;
|
||||||
tm_now->tm_mday += 1;
|
tm_now.tm_sec = 0;
|
||||||
time_t midnight = mktime(tm_now);
|
tm_now.tm_mday += 1;
|
||||||
|
time_t midnight = mktime(&tm_now);
|
||||||
return midnight;
|
return midnight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user