Created
January 27, 2015 07:18
-
-
Save rmcgibbo/7e599071a9ab973015f3 to your computer and use it in GitHub Desktop.
Macro to set the time on an ardunio using https://github.com/PaulStoffregen/Time from the __DATE__ and __TIME__ preprocessor macros.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SET_TIME() (setTime( \ | |
((__TIME__[0]-'0')*10 + (__TIME__[1]-'0')), \ | |
((__TIME__[3]-'0')*10 + (__TIME__[4]-'0')), \ | |
((__TIME__[6]-'0')*10 + (__TIME__[7]-'0')), \ | |
((__DATE__[4]-'0')*10 + (__DATE__[5]-'0')), \ | |
(__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 1 : 6) \ | |
: __DATE__ [2] == 'b' ? 2 \ | |
: __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 3 : 4) \ | |
: __DATE__ [2] == 'y' ? 5 \ | |
: __DATE__ [2] == 'l' ? 7 \ | |
: __DATE__ [2] == 'g' ? 8 \ | |
: __DATE__ [2] == 'p' ? 9 \ | |
: __DATE__ [2] == 't' ? 10 \ | |
: __DATE__ [2] == 'v' ? 11 \ | |
: 12), \ | |
((__DATE__[7]-'0')*1000 + (__DATE__[8]-'0')*100 + \ | |
(__DATE__[9]-'0')*10 + (__DATE__[10]-'0')) \ | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment