Skip to content

Instantly share code, notes, and snippets.

@gugu
Last active December 31, 2015 18:48
Show Gist options
  • Save gugu/8028967 to your computer and use it in GitHub Desktop.
Save gugu/8028967 to your computer and use it in GitHub Desktop.
#include <time.h>
#include <stdio.h>
int main() {
setenv("TZ", ":Europe/Berlin", 1);
tzset();
struct tm t = {0,21,2,25,9,98,0,0,-1};
struct tm t_min = {0,21,1,25,9,98,0,0,-1};
struct tm t_max = {0,21,4,25,9,98,0,0,-1};
printf("is_dst before: %d\n", t.tm_isdst);
// 909278460
printf("time: %d\n", timelocal(&t));
printf("is_dst after: %ld\n", t.tm_isdst);
timelocal(&t_min);
struct tm t1 = {0,21,2,25,9,98,0,0,-1};
printf("\n\nis_dst before: %d\n", t1.tm_isdst);
printf("%ld\n", timelocal(&t1));
// 909274860
printf("is_dst after: %d\n", t1.tm_isdst);
timelocal(&t_max);
struct tm t2 = {0,21,2,25,9,98,0,0,-1};
// 909278460
printf("\n\nis_dst before: %d\n", t2.tm_isdst);
printf("%ld\n", timelocal(&t2));
printf("is_dst after: %d\n", t2.tm_isdst);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment