Time zones [modified]
-
I've a weird problem making me crazy !!! I've to read a sequence of dates from a text file and convert these dates into time_t. I DON't want to take into account timezones and daylight savings, so the input date must be converted into the exact output date. So, i've avoided mktime() to convert from tm (filled up with string dates from source) to time_t. The nex solution i've used was to convert a SYSTEMTIME to a time_t with these functions (based on a similar function, UnixTimeToSystemTime(), in MSDN): void FileTimeToUnixTime(LPFILETIME pft, time_t *t) { LONGLONG ll; ll = pft->dwHighDateTime; ll <<= 32; ll |= pft->dwLowDateTime; ll = ll - 116444736000000000; *t = ll / 10000000; } void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t) { FILETIME ft; SystemTimeToFileTime(pst, &ft); FileTimeToUnixTime(&ft, t); } because I was sure that SystemTimeToFileTime() only converts to SYSTEMTIME format to FILETIME format without any other considerations like timezone or daylight saving. In my PC these work well. When I've run the code in another PC, the resulting date is 1 hour back. (it's very strange too, because that PC has the same date settings of mine). I can't achive the result to obatin a time_t that reflect the same source date, without variations caused by currenctly timezone and daylight saving settings. -- modified at 7:13 Thursday 3rd August, 2006
-
I've a weird problem making me crazy !!! I've to read a sequence of dates from a text file and convert these dates into time_t. I DON't want to take into account timezones and daylight savings, so the input date must be converted into the exact output date. So, i've avoided mktime() to convert from tm (filled up with string dates from source) to time_t. The nex solution i've used was to convert a SYSTEMTIME to a time_t with these functions (based on a similar function, UnixTimeToSystemTime(), in MSDN): void FileTimeToUnixTime(LPFILETIME pft, time_t *t) { LONGLONG ll; ll = pft->dwHighDateTime; ll <<= 32; ll |= pft->dwLowDateTime; ll = ll - 116444736000000000; *t = ll / 10000000; } void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t) { FILETIME ft; SystemTimeToFileTime(pst, &ft); FileTimeToUnixTime(&ft, t); } because I was sure that SystemTimeToFileTime() only converts to SYSTEMTIME format to FILETIME format without any other considerations like timezone or daylight saving. In my PC these work well. When I've run the code in another PC, the resulting date is 1 hour back. (it's very strange too, because that PC has the same date settings of mine). I can't achive the result to obatin a time_t that reflect the same source date, without variations caused by currenctly timezone and daylight saving settings. -- modified at 7:13 Thursday 3rd August, 2006
-
There is nothing General about this discussion. This is a specific programming question that should go in the specific forum for the language you are using.
Forgive me :) I'll post in the c++ thread ...