summaryrefslogtreecommitdiff
path: root/avr/cmd_date.c
diff options
context:
space:
mode:
Diffstat (limited to 'avr/cmd_date.c')
-rw-r--r--avr/cmd_date.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/avr/cmd_date.c b/avr/cmd_date.c
index bc93efc..2396783 100644
--- a/avr/cmd_date.c
+++ b/avr/cmd_date.c
@@ -31,26 +31,21 @@ command_ret_t do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
switch (argc) {
case 2: /* set date & time */
- if (strcmp_P(argv[1],PSTR("reset")) == 0) {
- my_puts_P(PSTR("Reset RTC...\n"));
- rtc_reset ();
- } else {
- /* 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"));
+ /* 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 */
@@ -60,7 +55,7 @@ command_ret_t do_date(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
my_puts_P(PSTR("## Get date failed\n"));
break;
}
- /* TODO: flash */
+ /* TODO: put weekdays[] in flash */
printf_P(PSTR("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) ?