1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-11 06:13:47 +01:00

Don't compile strptime unless its required (#6424)

This commit is contained in:
Gábor Poczkodi
2024-03-25 23:34:47 +01:00
committed by GitHub
parent f5ac1bd905
commit 7cb8f99884
2 changed files with 10 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
#ifdef USE_DATETIME
#include <regex>
#endif
#include "helpers.h"
#include "time.h" // NOLINT
@@ -64,6 +66,8 @@ std::string ESPTime::strftime(const std::string &format) {
return timestr;
}
#ifdef USE_DATETIME
bool ESPTime::strptime(const std::string &time_to_parse, ESPTime &esp_time) {
// clang-format off
std::regex dt_regex(R"(^
@@ -102,6 +106,8 @@ bool ESPTime::strptime(const std::string &time_to_parse, ESPTime &esp_time) {
return true;
}
#endif
void ESPTime::increment_second() {
this->timestamp++;
if (!increment_time_value(this->second, 0, 60))