- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
Perhaps this is very simple but.... I'd like to use the SysId component timestamp field for system validation purposes, but not as simple as the long lvalue compare the HAL does, what I want is to convert this timestamp value (seconds elapsed from january 1st, 1970) to year, month, day,... Has anyone done it before? Is there any code available for doing this convertion? Thanks,Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi 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
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page