I have 2 systems, in which system A sends time in UTC to system B.
System B converts it to local time, sets it using the Windows API, and then returns back the local time and timezone bios to system A. If the returned result does not match, System A retries.
time_t dateTime = X; //UTC time from System A
struct tm newDateTime;
_tzset();
localtime_s(&newDateTime, &dateTime);
SYSTEMTIME walltime; // Below values are filled from newDateTime, Below is example when issue comes.
walltime.wYear = 2024;
walltime.wMonth = 11;
walltime.wDay = 3;
walltime.wHour = 01;
walltime.wMinute = 59;
walltime.wSecond = 30;
if (!SetLocalTime(&walltime)) {
// ERROR handling
}
//After setting the time
DYNAMIC_TIME_ZONE_INFORMATION timeZoneInformation = { 0 };
DWORD result = GetDynamicTimeZoneInformation(&timeZoneInformation);
int bias = (result == TIME_ZONE_ID_DAYLIGHT) ? (timeZoneInformation.Bias + timeZoneInformation.DaylightBias) : (timeZoneInformation.Bias + timeZoneInformation.StandardBias)
std::cout << "Calculated Bias: " << bias << std::endl;
For the above scenario, if the timezone is central time (-6:00),
I want to get the calculated bios as -300 or -360 based on whether DST is applicable or lifted, irrespective of time correction happening.
The above code works in all the scenarios except for the ambiguous time period of 1AM-2AM, in which it should return a value based on whether DST is lifted.
Can anyone help me in how to handle this scenario?
7