| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef HW_TIME_H_
- #define HW_TIME_H_
- #include <time.h>
- #include "hplatform.h"
- typedef struct datetime_s {
- int year;
- int month;
- int day;
- int hour;
- int min;
- int sec;
- int ms;
- } datetime_t;
- #ifdef OS_WIN
- inline void sleep(unsigned int s) {
- Sleep(s*1000);
- }
- #endif
- inline void msleep(unsigned int ms) {
- #ifdef OS_WIN
- Sleep(ms);
- #else
- usleep(ms*1000);
- #endif
- }
- // ms
- inline unsigned int gettick() {
- #ifdef OS_WIN
- return GetTickCount();
- #else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv.tv_sec*1000 + tv.tv_usec/1000;
- #endif
- }
- // us
- inline unsigned int getclock() {
- return clock()*(unsigned long long)1000000 / CLOCKS_PER_SEC;
- }
- int month_atoi(const char* month);
- const char* month_itoa(int month);
- datetime_t get_datetime();
- datetime_t get_compile_datetime();
- #endif // HW_TIME_H_
|