📄 gettimeofday_r.c
字号:
#include <reent.h>#include <errno.h>#include <devices.h>#include <sys/time.h>#include <types.h>#include <sysdefs.h>#include <sysdefs.h>#include <time.h>//// note: MSDOS epoch is: 315532800 -- Jan 01, 1980 00:00:00//// note: unix epoch is: 0 -- Jan 01, 1970 00:00:00///*********************************************************** * * gettimeofday_r * return time in epoch seconds since Jan 01, 1970 ************************************************************/int _gettimeofday_r (struct _reent *r, struct timeval *tp, struct timezone *tzp){struct tm now;#ifdef HAS_CLOCK readRTC (&now); // adjust for differences between our clock and a "normal" clock. now.tm_year -= 1900; now.tm_mon -= 1; now.tm_yday -= 1;#else { time_t newTime; newTime = 0; localtime_r(&newTime, &now); }#endif tp->tv_sec = mktime(&now); tp->tv_usec = 0; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -