Skip to content

Commit ece522d

Browse files
committed
Removed code using <time.h> non-core library (ie. Epoch stuff)
I hate to undo even a little bit of Adam's good work, but in the interests of a robust core, I think it's best the references to time.h are removed, and the Epoch set/get along with it. RTC.cpp included <time.h>, which caused a compilation error when these are also included in code: #include <Time.h> #include <TimeLib.h> Some possible issues with Window lack of case sensitivity, refer here: https://forum.arduino.cc/index.php?topic=451360.0 Also with time.h (or Time.h?) being an optional extra install library to the Arduino IDE, best to leave it out of the core, especially if it can cause compilation errors.
1 parent 0af5eb0 commit ece522d

File tree

4 files changed

+0
-86
lines changed

4 files changed

+0
-86
lines changed

Diff for: libraries/RTC/examples/Example4_Set_Epoch/Example4_Set_Epoch.ino

-41
This file was deleted.

Diff for: libraries/RTC/keywords.txt

-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ RTC KEYWORD1
1313
#######################################
1414

1515
getTime KEYWORD2
16-
getEpoch KEYWORD2
1716

1817
setTime KEYWORD2
1918
setTimeToCompiler KEYWORD2
20-
setEpoch KEYWORD2
2119

2220
getAlarm KEYWORD2
2321
setAlarm KEYWORD2

Diff for: libraries/RTC/src/RTC.cpp

-41
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
#include "RTC.h"
6-
#include <time.h>
76

87
am_hal_rtc_time_t hal_time;
98
am_hal_rtc_time_t alm_time;
@@ -89,28 +88,6 @@ void APM3_RTC::setToCompilerTime()
8988
getTime();
9089
}
9190

92-
void APM3_RTC::setEpoch(uint32_t ts)
93-
{
94-
if (ts < EPOCH_TIME) {
95-
ts = EPOCH_TIME;
96-
}
97-
98-
struct tm tm;
99-
100-
time_t t = ts;
101-
struct tm* tmp = gmtime(&t);
102-
hal_time.ui32Weekday = 0;
103-
hal_time.ui32Century = 0;
104-
hal_time.ui32Year = tmp->tm_year - 100;
105-
hal_time.ui32Month = tmp->tm_mon + 1;
106-
hal_time.ui32DayOfMonth = tmp->tm_mday;
107-
hal_time.ui32Hour = tmp->tm_hour;
108-
hal_time.ui32Minute = tmp->tm_min;
109-
hal_time.ui32Second = tmp->tm_sec;
110-
hal_time.ui32Hundredths = 0;
111-
112-
am_hal_rtc_time_set(&hal_time); //Initialize the RTC with this date/time
113-
}
11491

11592
void APM3_RTC::getTime()
11693
{
@@ -127,24 +104,6 @@ void APM3_RTC::getTime()
127104
hundredths = hal_time.ui32Hundredths;
128105
}
129106

130-
uint32_t APM3_RTC::getEpoch()
131-
{
132-
am_hal_rtc_time_get(&hal_time);
133-
134-
struct tm tm;
135-
136-
tm.tm_isdst = -1;
137-
tm.tm_yday = 0;
138-
tm.tm_wday = 0;
139-
tm.tm_year = hal_time.ui32Year + 100; //Number of years since 1900.
140-
tm.tm_mon = hal_time.ui32Month - 1; //mktime is expecting 0 to 11 months
141-
tm.tm_mday = hal_time.ui32DayOfMonth;
142-
tm.tm_hour = hal_time.ui32Hour;
143-
tm.tm_min = hal_time.ui32Minute;
144-
tm.tm_sec = hal_time.ui32Second;
145-
146-
return mktime(&tm);
147-
}
148107

149108
void APM3_RTC::getAlarm()
150109
{

Diff for: libraries/RTC/src/RTC.h

-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ class APM3_RTC
99
APM3_RTC();
1010

1111
void getTime(); //Query the RTC for the current time/date
12-
uint32_t getEpoch(); //Return the current RTC time/date as UNIX Epoch time
1312

1413
void setTime(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund,
1514
uint8_t dayOfMonth, uint8_t month, uint16_t year); //Set current time to provided hundredths/seconds/etc
1615
void setToCompilerTime(); //Set to time when sketch was compiled
17-
void setEpoch(uint32_t ts); //Set current time to provided UNIX Epoch time
1816

1917
void getAlarm(); //Query the RTC for the current alarm time/date
2018
void setAlarm(uint8_t hour, uint8_t min, uint8_t sec, uint8_t hund, uint8_t dayOfMonth, uint8_t month); //Set alarm time to provided hundredths/seconds/etc

0 commit comments

Comments
 (0)