1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 15:12:06 +00:00

touch ups

This commit is contained in:
J. Nick Koston
2025-10-25 11:35:01 -07:00
parent ace2fce3a2
commit f8bbd8e32a
2 changed files with 3 additions and 3 deletions

View File

@@ -46,7 +46,7 @@ struct tm ESPTime::to_c_tm() {
return c_tm; return c_tm;
} }
std::string ESPTime::strftime(const char *format, size_t format_len) { std::string ESPTime::strftime(const char *format) {
struct tm c_tm = this->to_c_tm(); struct tm c_tm = this->to_c_tm();
char buf[128]; char buf[128];
size_t len = ::strftime(buf, sizeof(buf), format, &c_tm); size_t len = ::strftime(buf, sizeof(buf), format, &c_tm);
@@ -56,7 +56,7 @@ std::string ESPTime::strftime(const char *format, size_t format_len) {
return "ERROR"; return "ERROR";
} }
std::string ESPTime::strftime(const std::string &format) { return this->strftime(format.c_str(), format.size()); } std::string ESPTime::strftime(const std::string &format) { return this->strftime(format.c_str()); }
bool ESPTime::strptime(const std::string &time_to_parse, ESPTime &esp_time) { bool ESPTime::strptime(const std::string &time_to_parse, ESPTime &esp_time) {
uint16_t year; uint16_t year;

View File

@@ -55,7 +55,7 @@ struct ESPTime {
std::string strftime(const std::string &format); std::string strftime(const std::string &format);
/// @copydoc strftime(const std::string &format) /// @copydoc strftime(const std::string &format)
std::string strftime(const char *format, size_t format_len = 0); std::string strftime(const char *format);
/// Check if this ESPTime is valid (all fields in range and year is greater than 2018) /// Check if this ESPTime is valid (all fields in range and year is greater than 2018)
bool is_valid() const { return this->year >= 2019 && this->fields_in_range(); } bool is_valid() const { return this->year >= 2019 && this->fields_in_range(); }