#include #include #include #include /* Some common time zone name. */ #if defined _WIN32 && !defined __CYGWIN__ /* Cf. */ # define FRENCH_TZ "Romance Standard Time" #else /* Cf. */ //# define FRENCH_TZ "Europe/Paris" # define FRENCH_TZ "Europe/Berlin" #endif static void show_localtime_result (time_t t) { struct tm *result = localtime (&t); printf ("%ld -> %04d-%02d-%02d %02d:%02d:%02d DST=%d\n", (long) t, result->tm_year + 1900, result->tm_mon + 1, result->tm_mday, result->tm_hour, result->tm_min, result->tm_sec, result->tm_isdst); } int main (int argc, char *argv[]) { #if defined _WIN32 && !defined __CYGWIN__ _putenv ("TZ" "=" FRENCH_TZ); #else setenv ("TZ", FRENCH_TZ, 1); #endif show_localtime_result (1173578399); /* 2007-03-11 02:59:59 */ show_localtime_result (1173578401); /* 2007-03-11 03:00:01 */ show_localtime_result (1174784399); /* 2007-03-25 01:59:59 */ show_localtime_result (1174784401); /* 2007-03-25 03:00:01 */ return 0; } /* glibc, Cygwin: 1173578399 -> 2007-03-11 02:59:59 DST=0 1173578401 -> 2007-03-11 03:00:01 DST=0 1174784399 -> 2007-03-25 01:59:59 DST=0 1174784401 -> 2007-03-25 03:00:01 DST=1 Native Windows: 1173578399 -> 2007-03-11 01:59:59 DST=0 1173578401 -> 2007-03-11 03:00:01 DST=1 1174784399 -> 2007-03-25 01:59:59 DST=1 1174784401 -> 2007-03-25 02:00:01 DST=1 */