diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2015-04-11 12:13:18 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2015-04-11 12:13:18 -0600 |
commit | 03a22b61713b49d36b355c2f286cdfd58739bec5 (patch) | |
tree | 9eb46bda1662f9d6a9f81e4eefdb45c0e369ed52 /apps/nshlib/nsh_timcmds.c | |
parent | b80e8be652dfa52e97daa65aa3e550cf31cb2409 (diff) | |
download | px4-nuttx-03a22b61713b49d36b355c2f286cdfd58739bec5.tar.gz px4-nuttx-03a22b61713b49d36b355c2f286cdfd58739bec5.tar.bz2 px4-nuttx-03a22b61713b49d36b355c2f286cdfd58739bec5.zip |
Allow NSH date command with no RTC. This command is useful without an RTC too. Also, this permits testing on the simulator which never has an RTC
Diffstat (limited to 'apps/nshlib/nsh_timcmds.c')
-rw-r--r-- | apps/nshlib/nsh_timcmds.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/apps/nshlib/nsh_timcmds.c b/apps/nshlib/nsh_timcmds.c index 3fa1a06b6..992cd8ecb 100644 --- a/apps/nshlib/nsh_timcmds.c +++ b/apps/nshlib/nsh_timcmds.c @@ -65,7 +65,7 @@ * Private Data ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE static FAR const char * const g_datemontab[] = { "jan", "feb", "mar", "apr", "may", "jun", @@ -85,7 +85,7 @@ static FAR const char * const g_datemontab[] = * Name: date_month ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE static inline int date_month(FAR const char *abbrev) { int i; @@ -105,7 +105,7 @@ static inline int date_month(FAR const char *abbrev) * Name: date_gettime ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE static inline int date_showtime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name) { static const char format[] = "%b %d %H:%M:%S %Y"; @@ -139,7 +139,7 @@ static inline int date_showtime(FAR struct nsh_vtbl_s *vtbl, FAR const char *nam * Name: date_settime ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name, FAR char *newtime) { @@ -178,6 +178,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_mday = (int)result; /* Get the hours */ @@ -193,6 +194,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_hour = (int)result; /* Get the minutes */ @@ -208,6 +210,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_min = (int)result; /* Get the seconds */ @@ -223,6 +226,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name { goto errout_bad_parm; } + tm.tm_sec = (int)result; /* And finally the year */ @@ -238,6 +242,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 - 1900; /* Convert this to the right form, then set the timer */ @@ -251,6 +256,7 @@ static inline int date_settime(FAR struct nsh_vtbl_s *vtbl, FAR const char *name nsh_output(vtbl, g_fmtcmdfailed, name, "clock_settime", NSH_ERRNO); return ERROR; } + return OK; errout_bad_parm: @@ -267,7 +273,7 @@ errout_bad_parm: * Name: cmd_date ****************************************************************************/ -#if defined (CONFIG_RTC) && !defined(CONFIG_NSH_DISABLE_DATE) +#ifndef CONFIG_NSH_DISABLE_DATE int cmd_date(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { FAR char *newtime = NULL; |