mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 17:57:37 +08:00
tweak
This commit is contained in:
@@ -370,20 +370,22 @@ bool parse_posix_tz(const char *tz_string, ParsedTimezone &result) {
|
|||||||
result.dst_offset_seconds = result.std_offset_seconds - 3600;
|
result.dst_offset_seconds = result.std_offset_seconds - 3600;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse DST rules if present
|
// Parse DST rules if present (POSIX requires both start and end if any rules specified)
|
||||||
if (*p == ',') {
|
if (*p == ',') {
|
||||||
p++;
|
p++;
|
||||||
if (!internal::parse_dst_rule(p, result.dst_start)) {
|
if (!internal::parse_dst_rule(p, result.dst_start)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p == ',') {
|
// Second rule is required per POSIX
|
||||||
|
if (*p != ',') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
p++;
|
p++;
|
||||||
if (!internal::parse_dst_rule(p, result.dst_end)) {
|
if (!internal::parse_dst_rule(p, result.dst_end)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,6 +361,24 @@ TEST(PosixTzParser, MFormatInvalidDayOfWeek7) {
|
|||||||
EXPECT_FALSE(parse_posix_tz("EST5EDT,M3.2.7,M11.1.0", tz));
|
EXPECT_FALSE(parse_posix_tz("EST5EDT,M3.2.7,M11.1.0", tz));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(PosixTzParser, MissingEndRule) {
|
||||||
|
ParsedTimezone tz;
|
||||||
|
// POSIX requires both start and end rules if any rules are specified
|
||||||
|
EXPECT_FALSE(parse_posix_tz("EST5EDT,M3.2.0", tz));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PosixTzParser, MissingEndRuleJFormat) {
|
||||||
|
ParsedTimezone tz;
|
||||||
|
// POSIX requires both start and end rules if any rules are specified
|
||||||
|
EXPECT_FALSE(parse_posix_tz("EST5EDT,J60", tz));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PosixTzParser, MissingEndRulePlainDay) {
|
||||||
|
ParsedTimezone tz;
|
||||||
|
// POSIX requires both start and end rules if any rules are specified
|
||||||
|
EXPECT_FALSE(parse_posix_tz("EST5EDT,60", tz));
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Large offset tests
|
// Large offset tests
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user