Mark ESPTime comparison operators as const (#9335)

This commit is contained in:
Adrian Freund 2025-07-06 00:00:39 +02:00 committed by GitHub
parent 4e9e48e2e7
commit b0f8922056
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 10 deletions

View File

@ -226,11 +226,11 @@ int32_t ESPTime::timezone_offset() {
return offset;
}
bool ESPTime::operator<(ESPTime other) { return this->timestamp < other.timestamp; }
bool ESPTime::operator<=(ESPTime other) { return this->timestamp <= other.timestamp; }
bool ESPTime::operator==(ESPTime other) { return this->timestamp == other.timestamp; }
bool ESPTime::operator>=(ESPTime other) { return this->timestamp >= other.timestamp; }
bool ESPTime::operator>(ESPTime other) { return this->timestamp > other.timestamp; }
bool ESPTime::operator<(const ESPTime &other) const { return this->timestamp < other.timestamp; }
bool ESPTime::operator<=(const ESPTime &other) const { return this->timestamp <= other.timestamp; }
bool ESPTime::operator==(const ESPTime &other) const { return this->timestamp == other.timestamp; }
bool ESPTime::operator>=(const ESPTime &other) const { return this->timestamp >= other.timestamp; }
bool ESPTime::operator>(const ESPTime &other) const { return this->timestamp > other.timestamp; }
template<typename T> bool increment_time_value(T &current, uint16_t begin, uint16_t end) {
current++;

View File

@ -109,10 +109,10 @@ struct ESPTime {
void increment_second();
/// Increment this clock instance by one day.
void increment_day();
bool operator<(ESPTime other);
bool operator<=(ESPTime other);
bool operator==(ESPTime other);
bool operator>=(ESPTime other);
bool operator>(ESPTime other);
bool operator<(const ESPTime &other) const;
bool operator<=(const ESPTime &other) const;
bool operator==(const ESPTime &other) const;
bool operator>=(const ESPTime &other) const;
bool operator>(const ESPTime &other) const;
};
} // namespace esphome