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

This commit is contained in:
Gregory Nutt 2015-04-11 12:13:18 -06:00
parent 63c0de86fe
commit 5a110d08d9
3 changed files with 5 additions and 3 deletions

View File

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
<p>Last Updated: August 7, 2014</p>
<p>Last Updated: April 11, 2015</p>
</td>
</tr>
</table>
@ -1181,7 +1181,6 @@ date [-s &quot;MMM DD HH:MM:SS YYYY&quot;]
<p>
<b>Synopsis</b>.
Show or set the current date and time.
This command is only supported if the platform supported RTC hardware (<code>CONFIG_RTC=y</code>).
</p>
<p>
Only one format is used both on display and when setting the date/time:
@ -2568,7 +2567,7 @@ nsh>
</tr>
<tr>
<td><b><code>date</code></b></td>
<td><code>CONFIG_RTC</code></td>
<td><br></td>
<td><code>CONFIG_NSH_DISABLE_DATE</code></td>
</tr>
<tr>

View File

@ -288,6 +288,7 @@ endif
config TIME_EXTENDED
bool "Add day of week, year support"
default "n"
depends on !LIBC_LOCALTIME
---help---
Selecting TIME_EXTENDED adds tm_wday, tm_yday and tm_isdst
to the tm struct. This allows integration with 3rd party libraries

View File

@ -2158,6 +2158,7 @@ static time_t time2sub(struct tm *const tmp,
li = y + (1 < yourtm.tm_mon);
yourtm.tm_mday += year_lengths[isleap(li)];
}
while (yourtm.tm_mday > DAYSPERLYEAR)
{
li = y + (1 < yourtm.tm_mon);
@ -2167,6 +2168,7 @@ static time_t time2sub(struct tm *const tmp,
return -1;
}
}
for (;;)
{
i = mon_lengths[isleap(y)][yourtm.tm_mon];