"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
};
+#define RELOC(a) ((typeof(a))((unsigned long)(a) + gd->reloc_off))
+
int mk_date (char *, struct rtc_time *);
int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
+ DECLARE_GLOBAL_DATA_PTR;
struct rtc_time tm;
int rcode = 0;
switch (argc) {
case 2: /* set date & time */
if (strcmp(argv[1],"reset") == 0) {
- printf ("Reset RTC...\n");
+ puts ("Reset RTC...\n");
rtc_reset ();
} else {
/* initialize tm with current time */
rtc_get (&tm);
/* insert new date & time */
if (mk_date (argv[1], &tm) != 0) {
- printf ("## Bad date format\n");
+ puts ("## Bad date format\n");
return 1;
}
/* and write to RTC */
printf ("Date: %4d-%02d-%02d (%sday) Time: %2d:%02d:%02d\n",
tm.tm_year, tm.tm_mon, tm.tm_mday,
(tm.tm_wday<0 || tm.tm_wday>6) ?
- "unknown " : weekdays[tm.tm_wday],
+ "unknown " : RELOC(weekdays[tm.tm_wday]),
tm.tm_hour, tm.tm_min, tm.tm_sec);
return 0;
return (-1);
}
+/***************************************************/
+
+U_BOOT_CMD(
+ date, 2, 1, do_date,
+ "date - get/set/reset date & time\n",
+ "[MMDDhhmm[[CC]YY][.ss]]\ndate reset\n"
+ " - without arguments: print date & time\n"
+ " - with numeric argument: set the system date & time\n"
+ " - with 'reset' argument: reset the RTC\n"
+);
+
#endif /* CFG_CMD_DATE */