My timezone is United States Eastern Standard Time which is 5 hours behind UTC. Given that:
struct tm t = { 0, 30, 15, 10, 3, 112, 0, 0, -1 };
time_t utc_in_timet = _mkgmtime(&t);
struct tm tt = { 0 };
localtime_s(&tt, &utc_in_timet);
tt is off by one hour when localtime_s returns. I have 11:30 in there instead of 10:30.
What am I missing?
I have tried your code in my machine and it works correctly (my time zone is GMT+2). Since you are telling your system to check for daylight savings itself (the last parameter for the
tmis-1), it is actually using EDT and is thus giving you GMT-4.You can try replacing the month (
3) with2, so that the date would be March 10th, just before the daylight savings change; I bet you will get the expected 10:30 in that case.