File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -105,13 +105,14 @@ unsigned long TimeService::getLocalTime()
105
105
return utc + _timezone_offset;
106
106
}
107
107
108
- unsigned long TimeService::getTimeFromString (const String& timeString)
108
+ unsigned long TimeService::getTimeFromString (const String& timeString, const String& timeStringFormat )
109
109
{
110
110
struct tm t;
111
111
std::istringstream ss (timeString.c_str ());
112
- ss >> std::get_time (&t, " %Y %b %d %H:%M:%S " );
112
+ ss >> std::get_time (&t, timeStringFormat. c_str () );
113
113
114
114
if (!ss) {
115
+ DEBUG_ERROR (" ArduinoIoTCloudTCP::%s invalid timeString input" , __FUNCTION__);
115
116
return 0 ;
116
117
} else {
117
118
return mktime (&t);
Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ class TimeService
50
50
unsigned long getTime ();
51
51
unsigned long getLocalTime ();
52
52
void setTimeZoneData (int offset, unsigned int valid_until);
53
- static unsigned long getTimeFromString (const String& timeString);
53
+ /* Helper function to convert a timeString into a UNIX timestamp. The format specifiers match the POSIX function strptime()*/
54
+ static unsigned long getTimeFromString (const String& timeString, const String& timeStringFormat);
54
55
55
56
private:
56
57
You can’t perform that action at this time.
0 commit comments