mirror of
https://github.com/esphome/esphome.git
synced 2026-09-28 15:30:21 +00:00
tweak
This commit is contained in:
@@ -369,7 +369,7 @@ TEST(PosixTzParser, DstStartUSEastern2026) {
|
||||
ParsedTimezone tz;
|
||||
parse_posix_tz("EST5EDT,M3.2.0/2,M11.1.0/2", tz);
|
||||
|
||||
time_t dst_start = calculate_dst_transition(2026, tz.dst_start, tz.std_offset_seconds);
|
||||
time_t dst_start = internal::calculate_dst_transition(2026, tz.dst_start, tz.std_offset_seconds);
|
||||
struct tm tm;
|
||||
internal::epoch_to_tm_utc(dst_start, &tm);
|
||||
|
||||
@@ -385,7 +385,7 @@ TEST(PosixTzParser, DstEndUSEastern2026) {
|
||||
ParsedTimezone tz;
|
||||
parse_posix_tz("EST5EDT,M3.2.0/2,M11.1.0/2", tz);
|
||||
|
||||
time_t dst_end = calculate_dst_transition(2026, tz.dst_end, tz.dst_offset_seconds);
|
||||
time_t dst_end = internal::calculate_dst_transition(2026, tz.dst_end, tz.dst_offset_seconds);
|
||||
struct tm tm;
|
||||
internal::epoch_to_tm_utc(dst_end, &tm);
|
||||
|
||||
@@ -404,7 +404,7 @@ TEST(PosixTzParser, LastSundayOfMarch2026) {
|
||||
rule.week = 5;
|
||||
rule.day_of_week = 0;
|
||||
rule.time_seconds = 2 * 3600;
|
||||
time_t transition = calculate_dst_transition(2026, rule, 0);
|
||||
time_t transition = internal::calculate_dst_transition(2026, rule, 0);
|
||||
struct tm tm;
|
||||
internal::epoch_to_tm_utc(transition, &tm);
|
||||
EXPECT_EQ(tm.tm_mday, 29);
|
||||
@@ -419,7 +419,7 @@ TEST(PosixTzParser, LastSundayOfOctober2026) {
|
||||
rule.week = 5;
|
||||
rule.day_of_week = 0;
|
||||
rule.time_seconds = 3 * 3600;
|
||||
time_t transition = calculate_dst_transition(2026, rule, 0);
|
||||
time_t transition = internal::calculate_dst_transition(2026, rule, 0);
|
||||
struct tm tm;
|
||||
internal::epoch_to_tm_utc(transition, &tm);
|
||||
EXPECT_EQ(tm.tm_mday, 25);
|
||||
@@ -434,7 +434,7 @@ TEST(PosixTzParser, FirstSundayOfApril2026) {
|
||||
rule.week = 1;
|
||||
rule.day_of_week = 0;
|
||||
rule.time_seconds = 0;
|
||||
time_t transition = calculate_dst_transition(2026, rule, 0);
|
||||
time_t transition = internal::calculate_dst_transition(2026, rule, 0);
|
||||
struct tm tm;
|
||||
internal::epoch_to_tm_utc(transition, &tm);
|
||||
EXPECT_EQ(tm.tm_mday, 5);
|
||||
@@ -451,7 +451,7 @@ TEST(PosixTzParser, IsInDstUSEasternSummer) {
|
||||
|
||||
// July 4, 2026 12:00 UTC - definitely in DST
|
||||
time_t summer = make_utc(2026, 7, 4, 12);
|
||||
EXPECT_TRUE(is_in_dst(summer, tz));
|
||||
EXPECT_TRUE(internal::is_in_dst(summer, tz));
|
||||
}
|
||||
|
||||
TEST(PosixTzParser, IsInDstUSEasternWinter) {
|
||||
@@ -460,7 +460,7 @@ TEST(PosixTzParser, IsInDstUSEasternWinter) {
|
||||
|
||||
// January 15, 2026 12:00 UTC - definitely not in DST
|
||||
time_t winter = make_utc(2026, 1, 15, 12);
|
||||
EXPECT_FALSE(is_in_dst(winter, tz));
|
||||
EXPECT_FALSE(internal::is_in_dst(winter, tz));
|
||||
}
|
||||
|
||||
TEST(PosixTzParser, IsInDstNoDstTimezone) {
|
||||
@@ -469,7 +469,7 @@ TEST(PosixTzParser, IsInDstNoDstTimezone) {
|
||||
|
||||
// July 15, 2026 12:00 UTC
|
||||
time_t epoch = make_utc(2026, 7, 15, 12);
|
||||
EXPECT_FALSE(is_in_dst(epoch, tz));
|
||||
EXPECT_FALSE(internal::is_in_dst(epoch, tz));
|
||||
}
|
||||
|
||||
TEST(PosixTzParser, SouthernHemisphereDstSummer) {
|
||||
@@ -478,7 +478,7 @@ TEST(PosixTzParser, SouthernHemisphereDstSummer) {
|
||||
|
||||
// December 15, 2025 12:00 UTC - summer in NZ, should be in DST
|
||||
time_t nz_summer = make_utc(2025, 12, 15, 12);
|
||||
EXPECT_TRUE(is_in_dst(nz_summer, tz));
|
||||
EXPECT_TRUE(internal::is_in_dst(nz_summer, tz));
|
||||
}
|
||||
|
||||
TEST(PosixTzParser, SouthernHemisphereDstWinter) {
|
||||
@@ -487,7 +487,7 @@ TEST(PosixTzParser, SouthernHemisphereDstWinter) {
|
||||
|
||||
// July 15, 2026 12:00 UTC - winter in NZ, should NOT be in DST
|
||||
time_t nz_winter = make_utc(2026, 7, 15, 12);
|
||||
EXPECT_FALSE(is_in_dst(nz_winter, tz));
|
||||
EXPECT_FALSE(internal::is_in_dst(nz_winter, tz));
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -607,11 +607,11 @@ TEST(PosixTzParser, DstBoundaryJustBeforeSpringForward) {
|
||||
|
||||
// March 8, 2026 06:59:59 UTC = 01:59:59 EST (1 second before spring forward)
|
||||
time_t before_epoch = make_utc(2026, 3, 8, 6, 59, 59);
|
||||
EXPECT_FALSE(is_in_dst(before_epoch, tz));
|
||||
EXPECT_FALSE(internal::is_in_dst(before_epoch, tz));
|
||||
|
||||
// March 8, 2026 07:00:00 UTC = 02:00:00 EST -> 03:00:00 EDT (DST started)
|
||||
time_t after_epoch = make_utc(2026, 3, 8, 7);
|
||||
EXPECT_TRUE(is_in_dst(after_epoch, tz));
|
||||
EXPECT_TRUE(internal::is_in_dst(after_epoch, tz));
|
||||
}
|
||||
|
||||
TEST(PosixTzParser, DstBoundaryJustBeforeFallBack) {
|
||||
@@ -621,11 +621,11 @@ TEST(PosixTzParser, DstBoundaryJustBeforeFallBack) {
|
||||
|
||||
// November 1, 2026 05:59:59 UTC = 01:59:59 EDT (1 second before fall back)
|
||||
time_t before_epoch = make_utc(2026, 11, 1, 5, 59, 59);
|
||||
EXPECT_TRUE(is_in_dst(before_epoch, tz));
|
||||
EXPECT_TRUE(internal::is_in_dst(before_epoch, tz));
|
||||
|
||||
// November 1, 2026 06:00:00 UTC = 02:00:00 EDT -> 01:00:00 EST (DST ended)
|
||||
time_t after_epoch = make_utc(2026, 11, 1, 6);
|
||||
EXPECT_FALSE(is_in_dst(after_epoch, tz));
|
||||
EXPECT_FALSE(internal::is_in_dst(after_epoch, tz));
|
||||
}
|
||||
|
||||
} // namespace esphome::time::testing
|
||||
|
||||
Reference in New Issue
Block a user