From 01c23eace305c1f210b11ce552b12b0c0e6d964c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 30 Jan 2026 01:06:46 -0600 Subject: [PATCH] cleanups --- esphome/components/time/posix_tz.cpp | 6 ++++++ esphome/components/time/posix_tz.h | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/esphome/components/time/posix_tz.cpp b/esphome/components/time/posix_tz.cpp index 9584db568dd..e57d3b3a2f9 100644 --- a/esphome/components/time/posix_tz.cpp +++ b/esphome/components/time/posix_tz.cpp @@ -1,3 +1,7 @@ +#include "esphome/core/defines.h" + +#ifdef USE_TIME_TIMEZONE + #include "posix_tz.h" #include @@ -450,3 +454,5 @@ bool epoch_to_local_tm(time_t utc_epoch, const ParsedTimezone &tz, struct tm *ou } } // namespace esphome::time + +#endif // USE_TIME_TIMEZONE diff --git a/esphome/components/time/posix_tz.h b/esphome/components/time/posix_tz.h index d44c611fe8e..6dbb09296e5 100644 --- a/esphome/components/time/posix_tz.h +++ b/esphome/components/time/posix_tz.h @@ -1,5 +1,7 @@ #pragma once +#ifdef USE_TIME_TIMEZONE + #include #include @@ -12,14 +14,14 @@ enum class DSTRuleType : uint8_t { DAY_OF_YEAR, ///< Plain number: n (day 0-365, Feb 29 counted in leap years) }; -/// Rule for DST transition +/// Rule for DST transition (packed for 32-bit: 12 bytes) struct DSTRule { + int32_t time_seconds; ///< Seconds after midnight (default 7200 = 2:00 AM) + uint16_t day; ///< Day of year (for JULIAN_NO_LEAP and DAY_OF_YEAR) DSTRuleType type; ///< Type of rule uint8_t month; ///< Month 1-12 (for MONTH_WEEK_DAY) uint8_t week; ///< Week 1-5, 5 = last (for MONTH_WEEK_DAY) uint8_t day_of_week; ///< Day 0-6, 0 = Sunday (for MONTH_WEEK_DAY) - uint16_t day; ///< Day of year (for JULIAN_NO_LEAP and DAY_OF_YEAR) - int32_t time_seconds; ///< Seconds after midnight (default 7200 = 2:00 AM) }; /// Parsed POSIX timezone information @@ -123,3 +125,5 @@ time_t calculate_dst_transition(int year, const DSTRule &rule, int32_t base_offs } // namespace internal } // namespace esphome::time + +#endif // USE_TIME_TIMEZONE