Find the time zone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <time.h> | |
signed long getTZ () | |
{ | |
struct tm* timeStruct; | |
time_t timeValBase = 86400; /* I know an implementation in which time_t is unsigned */ | |
time_t timeVal; | |
timeStruct = gmtime(&timeValBase); /* parse as the universal time */ | |
timeVal = mktime(tp); /* intentionally treat as the local time in order to find the time zone */ | |
return (signed long)timeValBase - (signed long)timeVal; /* time zone in seconds, e.g. 32400 in Japan */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment