On Wed, 28 Jan 2009 20:57:04 +0100 Vincent Trouilliez <vincent.trouill...@modulonet.fr> wrote: >Hello, > >I am using the __DATE__ constant, to display it on screen >at power-up. >the screen is a 4x20 LCD, and the string returned by >__DATE__ is quite >long: "MMM DD YYYY". > >Is there a way to select a different (shorter in my case) >format, or is >it cast in stone ? > >I downloaded the heavy GCC 4.3.3 PDF manual, and among 636 >pages, the >only occurence of __DATE__ is in this sentence: > >"The definitions for __DATE__ and __TIME__ when >respectively, the date >and time of translation are not available (C90 6.8.8, C99 >6.10.8)." > >"not available" ? > >I thought maybe it's supplied by avr-libc then, but the >manual for that >doesn't has any, zero, mention of __DATE__ > >So it must be a gift from the AVR port of GCC then, but >where is it >documented ? > > >While I am at it, in the same vein, has anybody a trick to >retrieve >the program revision number from subversion, so I can >display that too >along with the compilation date ? > >TIA. > >Regards, > > >-- >Vince >
Hi, You can use the following MACROS and functions to get the values in integer format. You can then display the date and time in whatever format you desire. #define COMPILE_HOUR (((__TIME__[0]-'0')*10) + (__TIME__[1]-'0')) #define COMPILE_MINUTE (((__TIME__[3]-'0')*10) + (__TIME__[4]-'0')) #define COMPILE_SECOND (((__TIME__[6]-'0')*10) + (__TIME__[7]-'0')) unsigned char GetCompileHour(void) { unsigned char hour=COMPILE_HOUR; return(hour); } unsigned char GetCompileMinute(void) { unsigned char minute=COMPILE_MINUTE; return(minute); } unsigned char GetCompileSecond(void) { unsigned char second=COMPILE_SECOND; return(second); } #define YEAR ((((__DATE__ [7]-'0')*10+(__DATE__ [8]-'0'))*10+(__DATE__ [9]-'0'))*10+(__DATE__ [10]-'0')) /* Month: 0 - 11 */ #define MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 0 : 5) \ : __DATE__ [2] == 'b' ? 1 \ : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 2 : 3) \ : __DATE__ [2] == 'y' ? 4 \ : __DATE__ [2] == 'l' ? 6 \ : __DATE__ [2] == 'g' ? 7 \ : __DATE__ [2] == 'p' ? 8 \ : __DATE__ [2] == 't' ? 9 \ : __DATE__ [2] == 'v' ? 10 : 11) #define DAY ((__DATE__ [4]==' ' ? 0 : __DATE__ [4]-'0')*10+(__DATE__[5]-'0')) /********************************************************************\ * Return year in which this file was last compiled as an unsigned * integer. \********************************************************************/ unsigned short GetCompileYear(void) { unsigned short year=YEAR; return(year); } /********************************************************************\ * Return month in which this file was last compiled. * (0-11 for Jan - Dec) \********************************************************************/ unsigned char GetCompileMonth(void) { unsigned short month=MONTH; return(month); } /********************************************************************\ * Return the day of the month in which this file was last compiled \********************************************************************/ unsigned char GetCompileDay(void) { unsigned short day=DAY; return(day); } Regards Anton Erasmus _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list