Go to the documentation of this file. 21 #ifndef COMPILE_TIME_H_ 22 #define COMPILE_TIME_H_ 25 #define PST_OFFSET (8UL) 28 #define SEC_PER_MIN (60UL) 29 #define SEC_PER_HOUR (3600UL) 30 #define SEC_PER_DAY (86400UL) 31 #define SEC_PER_YEAR (SEC_PER_DAY*365) 34 #define CONV_STR2DEC_1(str, i) (str[i]>'0'?str[i]-'0':0) 35 #define CONV_STR2DEC_2(str, i) (CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0') 36 #define CONV_STR2DEC_3(str, i) (CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0') 37 #define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0') 40 #define GET_MONTH(str, i) (str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \ 41 str[i]=='F' && str[i+1]=='e' && str[i+2]=='b' ? 2 : \ 42 str[i]=='M' && str[i+1]=='a' && str[i+2]=='r' ? 3 : \ 43 str[i]=='A' && str[i+1]=='p' && str[i+2]=='r' ? 4 : \ 44 str[i]=='M' && str[i+1]=='a' && str[i+2]=='y' ? 5 : \ 45 str[i]=='J' && str[i+1]=='u' && str[i+2]=='n' ? 6 : \ 46 str[i]=='J' && str[i+1]=='u' && str[i+2]=='l' ? 7 : \ 47 str[i]=='A' && str[i+1]=='u' && str[i+2]=='g' ? 8 : \ 48 str[i]=='S' && str[i+1]=='e' && str[i+2]=='p' ? 9 : \ 49 str[i]=='O' && str[i+1]=='c' && str[i+2]=='t' ? 10 : \ 50 str[i]=='N' && str[i+1]=='o' && str[i+2]=='v' ? 11 : \ 51 str[i]=='D' && str[i+1]=='e' && str[i+2]=='c' ? 12 : 0) 54 #define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6) 55 #define __TIME_MINUTES__ CONV_STR2DEC_2(__TIME__, 3) 56 #define __TIME_HOURS__ CONV_STR2DEC_2(__TIME__, 0) 57 #define __TIME_DAYS__ CONV_STR2DEC_2(__DATE__, 4) 58 #define __TIME_MONTH__ GET_MONTH(__DATE__, 0) 59 #define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7) 62 #define _UNIX_TIMESTAMP_FDAY(year) \ 63 (((year) % 400) == 0UL ? 29UL : \ 64 (((year) % 100) == 0UL ? 28UL : \ 65 (((year) % 4) == 0UL ? 29UL : \ 69 #define _UNIX_TIMESTAMP_YDAY(year, month, day) \ 72 + (month >= 2 ? 31UL : 0UL) \ 73 + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) \ 74 + (month >= 4 ? 31UL : 0UL) \ 75 + (month >= 5 ? 30UL : 0UL) \ 76 + (month >= 6 ? 31UL : 0UL) \ 77 + (month >= 7 ? 30UL : 0UL) \ 78 + (month >= 8 ? 31UL : 0UL) \ 79 + (month >= 9 ? 31UL : 0UL) \ 80 + (month >= 10 ? 30UL : 0UL) \ 81 + (month >= 11 ? 31UL : 0UL) \ 82 + (month >= 12 ? 30UL : 0UL) \ 86 #define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \ 88 + minute * SEC_PER_MIN \ 89 + hour * SEC_PER_HOUR \ 90 + (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY \ 91 + (year - 1970UL) * SEC_PER_YEAR \ 92 + ((year - 1969UL) / 4UL) * SEC_PER_DAY \ 93 - ((year - 1901UL) / 100UL) * SEC_PER_DAY \ 94 + ((year - 1601UL) / 400UL) * SEC_PER_DAY \ 98 #define UNIX_TIMESTAMP _UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__) 99 #define UNIX_TIMESTAMP_UTC (UNIX_TIMESTAMP + (PST_OFFSET*SEC_PER_HOUR))