diff --git a/arch/arm/src/lpc43xx/lpc43_rtc.c b/arch/arm/src/lpc43xx/lpc43_rtc.c index f3db9f85988..13cf2345753 100644 --- a/arch/arm/src/lpc43xx/lpc43_rtc.c +++ b/arch/arm/src/lpc43xx/lpc43_rtc.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include diff --git a/arch/arm/src/stm32/stm32_rtcc.c b/arch/arm/src/stm32/stm32_rtcc.c index 634f6dca15b..503d635391a 100644 --- a/arch/arm/src/stm32/stm32_rtcc.c +++ b/arch/arm/src/stm32/stm32_rtcc.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index c53f1f5a91c..617982e5df1 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include "arm_internal.h" #include "stm32_rcc.h" diff --git a/arch/arm/src/stm32/stm32l15xxx_rtcc.c b/arch/arm/src/stm32/stm32l15xxx_rtcc.c index 7cec587c5bb..dfb650bd4e2 100644 --- a/arch/arm/src/stm32/stm32l15xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32l15xxx_rtcc.c @@ -33,7 +33,7 @@ #include #include -#include +#include #include diff --git a/arch/arm/src/stm32f7/stm32_rtc.c b/arch/arm/src/stm32f7/stm32_rtc.c index 673994ad555..708429990bc 100644 --- a/arch/arm/src/stm32f7/stm32_rtc.c +++ b/arch/arm/src/stm32f7/stm32_rtc.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include "arm_internal.h" #include "stm32_rcc.h" diff --git a/arch/arm/src/stm32h7/stm32_rtc.c b/arch/arm/src/stm32h7/stm32_rtc.c index 3edad720a87..7a86de48646 100644 --- a/arch/arm/src/stm32h7/stm32_rtc.c +++ b/arch/arm/src/stm32h7/stm32_rtc.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include "arm_internal.h" #include "stm32_rcc.h" diff --git a/arch/arm/src/stm32l4/stm32l4_rtc.c b/arch/arm/src/stm32l4/stm32l4_rtc.c index c186964ab42..ebc5060c9fb 100644 --- a/arch/arm/src/stm32l4/stm32l4_rtc.c +++ b/arch/arm/src/stm32l4/stm32l4_rtc.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include diff --git a/arch/arm/src/stm32wb/stm32wb_rtc.c b/arch/arm/src/stm32wb/stm32wb_rtc.c index 38a96aaccba..3b1a3325769 100644 --- a/arch/arm/src/stm32wb/stm32wb_rtc.c +++ b/arch/arm/src/stm32wb/stm32wb_rtc.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include "arm_internal.h" diff --git a/drivers/sensors/dhtxx.c b/drivers/sensors/dhtxx.c index b97f1e5c179..562c2290716 100644 --- a/drivers/sensors/dhtxx.c +++ b/drivers/sensors/dhtxx.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index 8ec8a689d60..294f528d816 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -202,6 +203,56 @@ # define INITIAL_SYSTEM_TIMER_TICKS 0 #endif +/* If Gregorian time is not supported, then neither is Julian */ + +#ifndef CONFIG_GREGORIAN_TIME +# undef CONFIG_JULIAN_TIME +#else +# define JD_OF_EPOCH 2440588 /* Julian Date of noon, J1970 */ + +# ifdef CONFIG_JULIAN_TIME +# define GREG_DUTC -141427 /* Default is October 15, 1582 */ +# define GREG_YEAR 1582 +# define GREG_MONTH 10 +# define GREG_DAY 15 +# endif /* CONFIG_JULIAN_TIME */ +#endif /* !CONFIG_GREGORIAN_TIME */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE (1900) +#define TM_WDAY_BASE TM_MONDAY + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + /**************************************************************************** * Public Types ****************************************************************************/ @@ -324,6 +375,57 @@ void clock_timespec_subtract(FAR const struct timespec *ts1, FAR const struct timespec *ts2, FAR struct timespec *ts3); +/**************************************************************************** + * Name: clock_isleapyear + * + * Description: + * Return true if the specified year is a leap year + * + ****************************************************************************/ + +int clock_isleapyear(int year); + +/**************************************************************************** + * Name: clock_daysbeforemonth + * + * Description: + * Get the number of days that occurred before the beginning of the month. + * + ****************************************************************************/ + +int clock_daysbeforemonth(int month, bool leapyear); + +/**************************************************************************** + * Name: clock_dayoftheweek + * + * Description: + * Get the day of the week + * + * Input Parameters: + * mday - The day of the month 1 - 31 + * month - The month of the year 1 - 12 + * year - the year including the 1900 + * + * Returned Value: + * Zero based day of the week 0-6, 0 = Sunday, 1 = Monday... 6 = Saturday + * + ****************************************************************************/ + +int clock_dayoftheweek(int mday, int month, int year); + +/**************************************************************************** + * Name: clock_calendar2utc + * + * Description: + * Calendar/UTC conversion based on algorithms from p. 604 + * of Seidelman, P. K. 1992. Explanatory Supplement to + * the Astronomical Almanac. University Science Books, + * Mill Valley. + * + ****************************************************************************/ + +time_t clock_calendar2utc(int year, int month, int day); + /**************************************************************************** * Name: clock_synchronize * diff --git a/include/nuttx/time.h b/include/nuttx/time.h deleted file mode 100644 index 7007225864b..00000000000 --- a/include/nuttx/time.h +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** - * include/nuttx/time.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __INCLUDE_NUTTX_TIME_H -#define __INCLUDE_NUTTX_TIME_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* If Gregorian time is not supported, then neither is Julian */ - -#ifndef CONFIG_GREGORIAN_TIME -# undef CONFIG_JULIAN_TIME -#else -# define JD_OF_EPOCH 2440588 /* Julian Date of noon, J1970 */ - -# ifdef CONFIG_JULIAN_TIME -# define GREG_DUTC -141427 /* Default is October 15, 1582 */ -# define GREG_YEAR 1582 -# define GREG_MONTH 10 -# define GREG_DAY 15 -# endif /* CONFIG_JULIAN_TIME */ -#endif /* !CONFIG_GREGORIAN_TIME */ - -#define SECSPERMIN 60 -#define MINSPERHOUR 60 -#define HOURSPERDAY 24 -#define DAYSPERWEEK 7 -#define DAYSPERNYEAR 365 -#define DAYSPERLYEAR 366 -#define MONSPERYEAR 12 - -#define TM_SUNDAY 0 -#define TM_MONDAY 1 -#define TM_TUESDAY 2 -#define TM_WEDNESDAY 3 -#define TM_THURSDAY 4 -#define TM_FRIDAY 5 -#define TM_SATURDAY 6 - -#define TM_JANUARY 0 -#define TM_FEBRUARY 1 -#define TM_MARCH 2 -#define TM_APRIL 3 -#define TM_MAY 4 -#define TM_JUNE 5 -#define TM_JULY 6 -#define TM_AUGUST 7 -#define TM_SEPTEMBER 8 -#define TM_OCTOBER 9 -#define TM_NOVEMBER 10 -#define TM_DECEMBER 11 - -#define TM_YEAR_BASE 1900 -#define TM_WDAY_BASE TM_MONDAY - -#define EPOCH_YEAR 1970 -#define EPOCH_WDAY TM_THURSDAY - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/**************************************************************************** - * Name: clock_isleapyear - * - * Description: - * Return true if the specified year is a leap year - * - ****************************************************************************/ - -int clock_isleapyear(int year); - -/**************************************************************************** - * Name: clock_daysbeforemonth - * - * Description: - * Get the number of days that occurred before the beginning of the month. - * - ****************************************************************************/ - -int clock_daysbeforemonth(int month, bool leapyear); - -/**************************************************************************** - * Name: clock_dayoftheweek - * - * Description: - * Get the day of the week - * - * Input Parameters: - * mday - The day of the month 1 - 31 - * month - The month of the year 1 - 12 - * year - the year including the 1900 - * - * Returned Value: - * Zero based day of the week 0-6, 0 = Sunday, 1 = Monday... 6 = Saturday - * - ****************************************************************************/ - -int clock_dayoftheweek(int mday, int month, int year); - -/**************************************************************************** - * Name: clock_calendar2utc - * - * Description: - * Calendar/UTC conversion based on algorithms from p. 604 - * of Seidelman, P. K. 1992. Explanatory Supplement to - * the Astronomical Almanac. University Science Books, - * Mill Valley. - * - ****************************************************************************/ - -time_t clock_calendar2utc(int year, int month, int day); - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __INCLUDE_NUTTX_TIME_H */ diff --git a/libs/libc/time/lib_asctimer.c b/libs/libc/time/lib_asctimer.c index a2bef81ff17..1d8b58e95d8 100644 --- a/libs/libc/time/lib_asctimer.c +++ b/libs/libc/time/lib_asctimer.c @@ -28,7 +28,7 @@ #include -#include +#include /**************************************************************************** * Private Data diff --git a/libs/libc/time/lib_calendar2utc.c b/libs/libc/time/lib_calendar2utc.c index 6e66be10563..a476bc7d970 100644 --- a/libs/libc/time/lib_calendar2utc.c +++ b/libs/libc/time/lib_calendar2utc.c @@ -28,7 +28,7 @@ #include #include -#include +#include /**************************************************************************** * Private Functions diff --git a/libs/libc/time/lib_dayofweek.c b/libs/libc/time/lib_dayofweek.c index 7acccf6fd63..f2219ef7624 100644 --- a/libs/libc/time/lib_dayofweek.c +++ b/libs/libc/time/lib_dayofweek.c @@ -27,7 +27,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/time/lib_daysbeforemonth.c b/libs/libc/time/lib_daysbeforemonth.c index b5ca1da1f85..ec77378c3d5 100644 --- a/libs/libc/time/lib_daysbeforemonth.c +++ b/libs/libc/time/lib_daysbeforemonth.c @@ -27,7 +27,7 @@ #include #include -#include +#include /**************************************************************************** * Private Data diff --git a/libs/libc/time/lib_gmtime.c b/libs/libc/time/lib_gmtime.c index a474fd86def..fb6a567775e 100644 --- a/libs/libc/time/lib_gmtime.c +++ b/libs/libc/time/lib_gmtime.c @@ -28,7 +28,7 @@ #include #include -#include +#include /**************************************************************************** * Public Functions diff --git a/libs/libc/time/lib_gmtimer.c b/libs/libc/time/lib_gmtimer.c index 64370d2802d..d78d8e2ce63 100644 --- a/libs/libc/time/lib_gmtimer.c +++ b/libs/libc/time/lib_gmtimer.c @@ -28,7 +28,6 @@ #include #include -#include #include /**************************************************************************** diff --git a/libs/libc/time/lib_isleapyear.c b/libs/libc/time/lib_isleapyear.c index ca37be2c7b4..eedec59aa56 100644 --- a/libs/libc/time/lib_isleapyear.c +++ b/libs/libc/time/lib_isleapyear.c @@ -24,7 +24,7 @@ #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/time/lib_localtime.c b/libs/libc/time/lib_localtime.c index 6faae1acd65..a777c87a1dd 100644 --- a/libs/libc/time/lib_localtime.c +++ b/libs/libc/time/lib_localtime.c @@ -60,7 +60,7 @@ #include -#include +#include #include #include #include diff --git a/libs/libc/time/lib_strftime.c b/libs/libc/time/lib_strftime.c index 68836677196..94b0219ecdb 100644 --- a/libs/libc/time/lib_strftime.c +++ b/libs/libc/time/lib_strftime.c @@ -28,7 +28,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/time/lib_strptime.c b/libs/libc/time/lib_strptime.c index 407ea911fb0..93a011eb9a3 100644 --- a/libs/libc/time/lib_strptime.c +++ b/libs/libc/time/lib_strptime.c @@ -36,7 +36,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/libs/libc/time/lib_timegm.c b/libs/libc/time/lib_timegm.c index 71cf39ac86c..cdaf97fb6f0 100644 --- a/libs/libc/time/lib_timegm.c +++ b/libs/libc/time/lib_timegm.c @@ -27,7 +27,7 @@ #include #include -#include +#include /**************************************************************************** * Pre-processor Definitions diff --git a/sched/clock/clock_initialize.c b/sched/clock/clock_initialize.c index 719618a5a8c..42d7eb3db67 100644 --- a/sched/clock/clock_initialize.c +++ b/sched/clock/clock_initialize.c @@ -36,7 +36,6 @@ #include #include -#include #include "clock/clock.h" #ifdef CONFIG_CLOCK_TIMEKEEPING