Skip to content

Instantly share code, notes, and snippets.

@MihailJP
Created April 20, 2013 16:55
Show Gist options
  • Save MihailJP/5426626 to your computer and use it in GitHub Desktop.
Save MihailJP/5426626 to your computer and use it in GitHub Desktop.
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