- (void) cmdtp; (void) flag;
-
- switch (argc) {
- case 2: /* set date & time */
- /* initialize tm with current time */
- rcode = rtc_get (&tm);
-
- if(!rcode) {
- /* insert new date & time */
- if (mk_date (argv[1], &tm) != 0) {
- my_puts_P(PSTR("## Bad date format\n"));
- break;
- }
- /* and write to RTC */
- rcode = rtc_set (&tm);
- if(rcode)
- my_puts_P(PSTR("## Set date failed\n"));
- } else {
- my_puts_P(PSTR("## Get date failed\n"));
- }
- /* FALL TROUGH */
- case 1: /* get date & time */
- rcode = rtc_get (&tm);
-
- if (rcode) {
- my_puts_P(PSTR("## Get date failed\n"));
- break;
- }
- printf_P(PSTR("Date: %4d-%02d-%02d ("),
- tm.tm_year, tm.tm_mon, tm.tm_mday);
- my_puts_P( (tm.tm_wday<0 || tm.tm_wday>6) ?
- PSTR("unknown ") : weekdays[tm.tm_wday]);
- printf_P(PSTR("day) Time: %2d:%02d:%02d\n"),
- tm.tm_hour, tm.tm_min, tm.tm_sec);
- break;
-
- default:
- rcode = CMD_RET_USAGE;
- }
-
- return rcode;
-}