forked from gnbdev/opengnb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgnb_time.h
40 lines (27 loc) · 798 Bytes
/
gnb_time.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef gnb_time_h
#define gnb_time_h
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__)
#define __UNIX_LIKE_OS__ 1
#endif
#include <stdint.h>
#include <time.h>
#include <unistd.h>
uint64_t gnb_timestamp_sec();
/*微秒*/
uint64_t gnb_timestamp_usec();
//format:"%Y_%m_%d_%H.%M.%S"
void gnb_now_timef(const char *format, char *buffer, size_t buffer_size);
void gnb_timef(const char *format, time_t t, char *buffer, size_t buffer_size);
/*
获得当前月的当天数字
*/
int gnb_now_mday();
int gnb_now_yday();
#define GNB_TIME_STRING_MAX 64
#ifdef __UNIX_LIKE_OS__
#define GNB_SLEEP_MILLISECOND(millisecond) usleep(1000 * millisecond)
#endif
#if defined(_WIN32)
#define GNB_SLEEP_MILLISECOND(millisecond) Sleep(millisecond)
#endif
#endif