7 time_t timegm(struct tm *tm)
10 t -= mktime(gmtime(&t)) - (int)mktime(localtime(&t));
14 int get_time_zone(time_t t)
16 struct tm *tm = gmtime(&t);
24 return mktime(&tm_utc) - mktime(tm);
29 time_t t = time(NULL);
30 struct tm *tm_local = localtime(&t);
31 struct tm *tm_gmt = gmtime(&t);
34 diff = timegm(tm_local) - (int)mktime(tm_local);
36 printf("gmt1=%d\n", t);
37 printf("loc1=%d\n", t + 36000);
39 printf("loc2=%d\n", mktime(tm_local));
40 printf("gmt2=%d\n", timegm(tm_local));
42 printf("diff=%d\n", diff);
44 printf("tz=%d\n", get_time_zone(t));