E
Erik Cato
Hi group!
Anyone know a way to convert the __DATE__ predefined macro into a
unsigned int representing the current date? It should
be possible to make out what date it was from the beginning.
My idéa was this format: ((Year - 2000)*12 + (month - 1))*31 + day
So 12 Dec 2003 would result in: ((2003 - 2000)*12 + (12 - 1))*31 + 12 = 1469
<OT>
What im trying to accomplish is to display a number representing
the build date of the code in a 4-digit 7-segment display.
</OT>
Preferbly i would have a solution that does it at compile time?
Something like this:
#define DATE_AS_INT /* something nice here */
displayAsInt(DATE_AS_INT);
The next best thing is a function returning the int. But i cannot use
any library functions.
Like this
unsigned int getDateAsInt()
{
/* Code goes here */
}
displayAsInt(getDateAsInt());
The reason for the somewhat strange constraints is that im developing for
an embedded system and im having a little short on code memory.
Greatful for any suggestion!
//Erik
Anyone know a way to convert the __DATE__ predefined macro into a
unsigned int representing the current date? It should
be possible to make out what date it was from the beginning.
My idéa was this format: ((Year - 2000)*12 + (month - 1))*31 + day
So 12 Dec 2003 would result in: ((2003 - 2000)*12 + (12 - 1))*31 + 12 = 1469
<OT>
What im trying to accomplish is to display a number representing
the build date of the code in a 4-digit 7-segment display.
</OT>
Preferbly i would have a solution that does it at compile time?
Something like this:
#define DATE_AS_INT /* something nice here */
displayAsInt(DATE_AS_INT);
The next best thing is a function returning the int. But i cannot use
any library functions.
Like this
unsigned int getDateAsInt()
{
/* Code goes here */
}
displayAsInt(getDateAsInt());
The reason for the somewhat strange constraints is that im developing for
an embedded system and im having a little short on code memory.
Greatful for any suggestion!
//Erik