Files
raven/testdata/native_loader/time_zone_rules_client.c
T
Raymond Bennett 3086e103dd test: check the daylight saving rules of a zone
Under TZ=America/New_York, GetTimeZoneInformation gives the US rules (first
Sunday of November and second Sunday of March at 2:00, an hour apart), and
GetTimeZoneInformationForYear the same for 2030.

Assisted-by: Claude Code:claude-opus-5-5
AI-Scope: the test client and its registration

(cherry picked from commit ac6e590c9175a6e7236a751d0f4559d8ec34ffd5)
2026-10-28 23:16:28 -07:00

28 lines
1.1 KiB
C

#include <windows.h>
// The daylight saving rules of America/New_York (the test sets TZ): standard time starts on the first Sunday of November at 2:00,
// daylight time on the second Sunday of March at 2:00, an hour ahead; GetTimeZoneInformationForYear gives the same rules for 2030.
// Returns 0, or the number of the check that failed.
static int rule(const SYSTEMTIME *date, WORD month, WORD occurrence)
{
return date->wYear == 0 && date->wMonth == month && date->wDayOfWeek == 0 && date->wDay == occurrence && date->wHour == 2 && date->wMinute == 0;
}
int raven_entry(void)
{
TIME_ZONE_INFORMATION zone;
const DWORD result = GetTimeZoneInformation(&zone);
if (result != TIME_ZONE_ID_STANDARD && result != TIME_ZONE_ID_DAYLIGHT)
return 1;
if (zone.Bias != 300 || zone.DaylightBias != -60 || zone.StandardBias != 0)
return 2;
if (!rule(&zone.StandardDate, 11, 1) || !rule(&zone.DaylightDate, 3, 2))
return 3;
TIME_ZONE_INFORMATION later;
if (!GetTimeZoneInformationForYear(2030, NULL, &later))
return 4;
if (!rule(&later.StandardDate, 11, 1) || !rule(&later.DaylightDate, 3, 2))
return 5;
return 0;
}