Forum Discussion
Altera_Forum
Honored Contributor
20 years agoHi VLorenzo,
> I want is to convert this timestamp value (seconds elapsed from january 1st, 1970) to > year, month, day, <<snip>> > Has anyone done it before? Is there any code available for doing this convertion? Yes, the u-boot code supports this. Here's a snip of code from cpu/nios2/sysid.c (code is available at: http://www.psyent.com/download (http://www.psyent.com/download) )void display_sysid (void)
{
struct nios_sysid_t *sysid = (struct nios_sysid_t *)CFG_NIOS_SYSID_BASE;
struct tm t;
char asc;
time_t stamp;
stamp = readl (&sysid->timestamp);
localtime_r (&stamp, &t);
asctime_r (&t, asc);
printf ("SYSID : %08x, %s", readl (&sysid->id), asc);
} I believe the hal has support for asctime_r and localtime_r ... if not, you can just hoist the code from the u-boot sources. Regards, --Scott