diff --git a/Include/auROXTL/auBuildTime.hpp b/Include/auROXTL/auBuildTime.hpp index 30dc21e..d336f38 100644 --- a/Include/auROXTL/auBuildTime.hpp +++ b/Include/auROXTL/auBuildTime.hpp @@ -8,20 +8,20 @@ ***/ // extracts 1..4 characters from a string and interprets it as a decimal value -#define __CONV_STR2DEC_1(str, i) (str[i]>'0'?str[i]-'0':0) -#define __CONV_STR2DEC_2(str, i) (__CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0') -#define __CONV_STR2DEC_3(str, i) (__CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0') -#define __CONV_STR2DEC_4(str, i) (__CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0') +#define __AU_CONV_STR2DEC_1(str, i) (str[i]>'0'?str[i]-'0':0) +#define __AU_CONV_STR2DEC_2(str, i) (__AU_CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0') +#define __AU_CONV_STR2DEC_3(str, i) (__AU_CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0') +#define __AU_CONV_STR2DEC_4(str, i) (__AU_CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0') // Some definitions for calculation -#define __SEC_PER_MIN 60UL -#define __SEC_PER_HOUR 3600UL -#define __SEC_PER_DAY 86400UL -#define __SEC_PER_YEAR (__SEC_PER_DAY*365) -#define __UNIX_START_YEAR 1970UL +#define __AU_SEC_PER_MIN 60UL +#define __AU_SEC_PER_HOUR 3600UL +#define __AU_SEC_PER_DAY 86400UL +#define __AU_SEC_PER_YEAR (__AU_SEC_PER_DAY*365) +#define __AU_UNIX_START_YEAR 1970UL // Custom "glue logic" to convert the month name to a usable number -#define __GET_MONTH(str, i) (str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \ +#define __AU_GET_MONTH(str, i) (str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \ str[i]=='F' && str[i+1]=='e' && str[i+2]=='b' ? 2 : \ str[i]=='M' && str[i+1]=='a' && str[i+2]=='r' ? 3 : \ str[i]=='A' && str[i+1]=='p' && str[i+2]=='r' ? 4 : \ @@ -34,40 +34,39 @@ str[i]=='N' && str[i+1]=='o' && str[i+2]=='v' ? 11 : \ str[i]=='D' && str[i+1]=='e' && str[i+2]=='c' ? 12 : 0) -#define __GET_MONTH2DAYS(month) ((month == 1 ? 0 : 31 + \ - (month == 2 ? 0 : 28 + \ - (month == 3 ? 0 : 31 + \ - (month == 4 ? 0 : 30 + \ - (month == 5 ? 0 : 31 + \ - (month == 6 ? 0 : 30 + \ - (month == 7 ? 0 : 31 + \ - (month == 8 ? 0 : 31 + \ - (month == 9 ? 0 : 30 + \ - (month == 10 ? 0 : 31 + \ - (month == 11 ? 0 : 30)))))))))))) +#define __AU_GET_MONTH2DAYS(month) ((month == 1 ? 0 : 31 + \ + (month == 2 ? 0 : 28 + \ + (month == 3 ? 0 : 31 + \ + (month == 4 ? 0 : 30 + \ + (month == 5 ? 0 : 31 + \ + (month == 6 ? 0 : 30 + \ + (month == 7 ? 0 : 31 + \ + (month == 8 ? 0 : 31 + \ + (month == 9 ? 0 : 30 + \ + (month == 10 ? 0 : 31 + \ + (month == 11 ? 0 : 30)))))))))))) -#define __TIME_SECONDS__ __CONV_STR2DEC_2(__TIME__, 6) -#define __TIME_MINUTES__ __CONV_STR2DEC_2(__TIME__, 3) -#define __TIME_HOURS__ __CONV_STR2DEC_2(__TIME__, 0) -#define __TIME_DAYS__ __CONV_STR2DEC_2(__DATE__, 4) -#define __TIME_MONTH__ __GET_MONTH(__DATE__, 0) -#define __TIME_YEARS__ __CONV_STR2DEC_4(__DATE__, 7) +#define __AU_TIME_SECONDS__ __AU_CONV_STR2DEC_2(__TIME__, 6) +#define __AU_TIME_MINUTES__ __AU_CONV_STR2DEC_2(__TIME__, 3) +#define __AU_TIME_HOURS__ __AU_CONV_STR2DEC_2(__TIME__, 0) +#define __AU_TIME_DAYS__ __AU_CONV_STR2DEC_2(__DATE__, 4) +#define __AU_TIME_MONTH__ __AU_GET_MONTH(__DATE__, 0) +#define __AU_TIME_YEARS__ __AU_CONV_STR2DEC_4(__DATE__, 7) -#define GET_LEAP_DAYS ((__TIME_YEARS__-1968)/4 - (__TIME_MONTH__ <=2 ? 1 : 0)) // Days in February -#define _UNIX_TIMESTAMP_FDAY(year) \ +#define __AU_UNIX_TIMESTAMP_FDAY(year) \ (((year) % 400) == 0UL ? 29UL : \ (((year) % 100) == 0UL ? 28UL : \ (((year) % 4) == 0UL ? 29UL : \ 28UL))) // Days in the year -#define _UNIX_TIMESTAMP_YDAY(year, month, day) \ +#define __AU_UNIX_TIMESTAMP_YDAY(year, month, day) \ ( \ /* January */ day \ /* February */ + (month >= 2 ? 31UL : 0UL) \ - /* March */ + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) \ + /* March */ + (month >= 3 ? __AU_UNIX_TIMESTAMP_FDAY(year) : 0UL) \ /* April */ + (month >= 4 ? 31UL : 0UL) \ /* May */ + (month >= 5 ? 30UL : 0UL) \ /* June */ + (month >= 6 ? 31UL : 0UL) \ @@ -80,43 +79,45 @@ ) // get the UNIX timestamp from a digits representation -#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \ +#define __AU_UNIX_TIMESTAMP(year, month, day, hour, minute, second) \ ( /* time */ second \ - + minute *__SEC_PER_MIN \ - + hour *__SEC_PER_HOUR \ - + /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) *__SEC_PER_DAY \ - + /* year */ (year - 1970UL) *__SEC_PER_YEAR \ - + ((year - 1969UL) / 4UL) *__SEC_PER_DAY \ - - ((year - 1901UL) / 100UL) *__SEC_PER_DAY \ - + ((year - 1601UL) / 400UL) *__SEC_PER_DAY \ + + minute *__AU_SEC_PER_MIN \ + + hour *__AU_SEC_PER_HOUR \ + + /* year day (month + day) */ (__AU_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) *__AU_SEC_PER_DAY \ + + /* year */ (year - 1970UL) *__AU_SEC_PER_YEAR \ + + ((year - 1969UL) / 4UL) *__AU_SEC_PER_DAY \ + - ((year - 1901UL) / 100UL) *__AU_SEC_PER_DAY \ + + ((year - 1601UL) / 400UL) *__AU_SEC_PER_DAY \ ) static constexpr AuUInt64 AuGetBuildTimeUnix() { - return _UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__); + return AuUInt64(__AU_UNIX_TIMESTAMP(__AU_TIME_YEARS__, __AU_TIME_MONTH__, __AU_TIME_DAYS__, __AU_TIME_HOURS__, __AU_TIME_MINUTES__, __AU_TIME_SECONDS__)) * 1000ull; } static constexpr AuUInt64 AuGetBuildTime() { - return AuGetBuildTimeUnix() - 999'080'100ull; + return AuGetBuildTimeUnix() - 999'080'100'000ull; } -#undef __TIME_SECONDS__ -#undef __TIME_MINUTES__ -#undef __TIME_HOURS__ -#undef __TIME_DAYS__ -#undef __TIME_MONTH__ -#undef __TIME_YEARS__ -#undef __GET_MONTH -#undef __GET_MONTH2DAYS -#undef __CONV_STR2DEC_1 -#undef __CONV_STR2DEC_2 -#undef __CONV_STR2DEC_3 -#undef __CONV_STR2DEC_4 -#undef __SEC_PER_MIN -#undef __SEC_PER_HOUR -#undef __SEC_PER_DAY -#undef __SEC_PER_YEAR -#undef __UNIX_START_YEAR +#undef __AU_TIME_SECONDS__ +#undef __AU_TIME_MINUTES__ +#undef __AU_TIME_HOURS__ +#undef __AU_TIME_DAYS__ +#undef __AU_TIME_MONTH__ +#undef __AU_TIME_YEARS__ +#undef __AU_GET_MONTH +#undef __AU_GET_MONTH2DAYS +#undef __AU_CONV_STR2DEC_1 +#undef __AU_CONV_STR2DEC_2 +#undef __AU_CONV_STR2DEC_3 +#undef __AU_CONV_STR2DEC_4 +#undef __AU_SEC_PER_MIN +#undef __AU_SEC_PER_HOUR +#undef __AU_SEC_PER_DAY +#undef __AU_SEC_PER_YEAR +#undef __AU_UNIX_START_YEAR +#undef __AU_UNIX_TIMESTAMP_FDAY +#undef __AU_UNIX_TIMESTAMP #define AURORA_BUILD_TIME AuGetBuildTime() \ No newline at end of file