Fixed RTC and Ethernet drivers, with NTP
This commit is contained in:
@@ -157,12 +157,27 @@ namespace drivers
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string PCF85063::getTimeStr() {
|
||||
const std::string PCF85063::getTimeStr()
|
||||
{
|
||||
datetime_t dt;
|
||||
readDatetime(dt);
|
||||
return datetime2str(dt);
|
||||
}
|
||||
|
||||
PCF85063::datetime_t PCF85063::fromEpoch(time_t currentTime)
|
||||
{
|
||||
PCF85063::datetime_t tm;
|
||||
struct tm *localTime = std::localtime(¤tTime);
|
||||
tm.year = localTime->tm_year + 1900;
|
||||
tm.month = localTime->tm_mon + 1;
|
||||
tm.day = localTime->tm_mday;
|
||||
tm.dotw = localTime->tm_wday;
|
||||
tm.hour = localTime->tm_hour;
|
||||
tm.minute = localTime->tm_min;
|
||||
tm.second = localTime->tm_sec;
|
||||
return tm;
|
||||
}
|
||||
|
||||
const std::string PCF85063::datetime2str(datetime_t &datetime)
|
||||
{
|
||||
tm dtime;
|
||||
@@ -171,7 +186,7 @@ namespace drivers
|
||||
dtime.tm_hour = datetime.hour;
|
||||
dtime.tm_wday = datetime.dotw;
|
||||
dtime.tm_mday = datetime.day;
|
||||
dtime.tm_mon = datetime.month;
|
||||
dtime.tm_mon = datetime.month - 1;
|
||||
dtime.tm_year = datetime.year - 1900; // time offset in structure according cpp reference
|
||||
return std::string(std::asctime(&dtime));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user