Skip to content

Instantly share code, notes, and snippets.

Created April 20, 2013 16:55
What would you like to do?
Find the time zone
#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