Hello Garvan,
I tested your posted timetest.exe while in Holland, and it worked, but that was not much of a test, was it? I am in Bangkok (+7GMT) now and it does not work here.
Test for me, in the sense that if localtime() is working, there is no fundamental flaw in calculating the timezone offset. If only _ftime() is wrong, I should look in one place for the problem. If also localtime() is wrong, I should look at the "bigger picture". This is why I wanted as many people as possible, from different timezones, to report the results.
Is the function _tzset(); needed? VC++ seams to work with or without it, and I could not find it in PellesC.
According to the docs, the _tzset function uses the current setting of the environment variable TZ to assign values to three global variables.
I have similar code, that checks the environment variable TZ, but it's called automatically - no need to call any _tzset function (if I can't find the TZ variable, I fall back and ask Windows about the "TZ" value, which is the parsed/analyzed).
I tried changing the Windows timezone setting, on my Swedish Windows XP, to various zones over the world (+/- many hours from GMT). It worked for most places, but not for some. I wasn't sure if this is because my Swedish version lacks some "setting files", or if there is a problem *sometimes*.
Pelle