1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-10 22:03:46 +01:00

Add datetime entities (#6513)

This commit is contained in:
Jesse Hills
2024-04-26 09:19:54 +12:00
committed by GitHub
parent bcef64a6fa
commit 8ef7b41c91
51 changed files with 1430 additions and 55 deletions

View File

@@ -178,6 +178,15 @@ void ESPTime::recalc_timestamp_utc(bool use_day_of_year) {
this->timestamp = res;
}
void ESPTime::recalc_timestamp_local(bool use_day_of_year) {
this->recalc_timestamp_utc(use_day_of_year);
this->timestamp -= ESPTime::timezone_offset();
ESPTime temp = ESPTime::from_epoch_local(this->timestamp);
if (temp.is_dst) {
this->timestamp -= 3600;
}
}
int32_t ESPTime::timezone_offset() {
int32_t offset = 0;
time_t now = ::time(nullptr);