summaryrefslogtreecommitdiff
path: root/nuttx/lib/lib_mktime.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/lib/lib_mktime.c')
-rw-r--r--nuttx/lib/lib_mktime.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/nuttx/lib/lib_mktime.c b/nuttx/lib/lib_mktime.c
index 594a0672b..46e16c50f 100644
--- a/nuttx/lib/lib_mktime.c
+++ b/nuttx/lib/lib_mktime.c
@@ -86,7 +86,7 @@
****************************************************************************/
#ifdef CONFIG_GREGORIAN_TIME
-time_t mktime(struct tm *tp)
+time_t mktime(const struct tm *tp)
{
time_t ret;
time_t jdn;
@@ -114,7 +114,7 @@ time_t mktime(struct tm *tp)
* seconds, etc. apply.
*/
-time_t mktime(struct tm *tp)
+time_t mktime(const struct tm *tp)
{
unsigned int days;
@@ -126,16 +126,9 @@ time_t mktime(struct tm *tp)
days += (tp->tm_year - 69) >> 2;
- /* Add in the days up to the beginning of this month (ignoring any possible leap day). */
+ /* Add in the days up to the beginning of this month. */
- days += (time_t)g_daysbeforemonth[tp->tm_mon];
-
- /* Add in the leap day for this year (months are zero based) */
-
- if (tp->tm_mon >= 2 && clock_isleapyear(tp->tm_year + 1900))
- {
- days++;
- }
+ days += (time_t)clock_daysbeforemonth(tp->tm_mon, clock_isleapyear(tp->tm_year + 1900));
/* Add in the days since the beginning of this month (days are 1-based). */