All pastes #150984 Raw Edit

Anonymous

public c v1 · immutable
#150984 ·published 2006-08-27 15:37 UTC
rendered paste body
// compile: gcc gmt_offset.c -o gmt_offset#include <time.h>int main() {    struct tm now_tm, gmt_tm;    time_t now_t, gmt_t, offset;    now_t=time(0);    gmt_tm=*gmtime(&now_t);    gmt_t=mktime(&gmt_tm);    offset=now_t-gmt_t;    // daylight savings time    now_tm=*localtime(&now_t);    if (now_tm.tm_isdst) {        offset+=3600;    }    // convert from seconds to hours    if (offset) {        offset/=3600;    }    printf("%d\n",offset);    return 0;}