From 12ede7f8e242f87c62ad3e7739d6a6452be813a1 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 1 Sep 2011 17:56:03 +0000 Subject: Fix errors in gmtime and gmtime_r git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3933 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 2 ++ apps/nshlib/README.txt | 12 ++++++++++++ apps/nshlib/nsh_timcmds.c | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index b3b50ca19..73eada367 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -102,3 +102,5 @@ of circles. * apps/system/i2c: Add an I2C test tool that should help to bring up I2C devices (when it is fully functional). + * apps/nshlib/nsh_timcmds.c: Add the date command that can be used to + show or set the time (only if CONFIG_RTC is set). diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt index 8435f6317..fad1ac104 100644 --- a/apps/nshlib/README.txt +++ b/apps/nshlib/README.txt @@ -262,6 +262,18 @@ o cp Copy of the contents of the file at to the location in the filesystem indicated by +o date [-s "MMM DD HH:MM:SS YYYY"] + + Show or set the current date and time. This command is only supported + if the platform supported RTC hardware (CONFIG_RTC=y). + + Only one format is used both on display and when setting the date/time: + MMM DD HH:MM:SS YYYY. For example, + + data -s "Sep 1 11:30:00 2011" + + 24-hour time format is assumed. + o dd if= of= [bs=] [count=] [skip=] Copy blocks from to . or may diff --git a/apps/nshlib/nsh_timcmds.c b/apps/nshlib/nsh_timcmds.c index bf5e6cd5d..04a79e77d 100644 --- a/apps/nshlib/nsh_timcmds.c +++ b/apps/nshlib/nsh_timcmds.c @@ -124,7 +124,7 @@ static inline int date_showtime(FAR struct nsh_vtbl_s *vtbl, FAR const char *nam /* Break the current time up into the format needed by strftime */ - (void)gmtime_r((FAR const time_t*)ts.tv_sec, &tm); + (void)gmtime_r((FAR const time_t*)&ts.tv_sec, &tm); /* Show the current time in the requested format */ @@ -166,7 +166,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name /* Get the day of the month. NOTE: Accepts day-of-month up to 31 for all months */ - token = strtok_r(newtime, " \t",&saveptr); + token = strtok_r(NULL, " \t",&saveptr); if (token == NULL) { goto errout_bad_parm; @@ -237,7 +237,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } - tm.tm_year = (int)result; + tm.tm_year = (int)result - 1900; /* Convert this to the right form, then set the timer */ -- cgit v1.2.3