(oops, the mailing list wasn't addressed in previous copy).

Erez:
> struct tm time_str;
> ...
> int d=timegm(&time_str)-timelocal(&time_str);
> printf("%d\n",d);
> 
> 
> prints 7200 (which is 2*3600 -> two hours).
> 
> 
> any idea ?
> or in in other words, how the f...@#k i get the offset from GMT c-code ?

glibc-specific solution is easy:

        struct tm       *tm;
        time_t          t;

        t = time(NULL);
        tm = localtime(&t);
        printf("OFF=%ld\n", tm->tm_gmtoff);

My system output:
        OFF=10800 # this is 3 hours


-- 
Oron Peled                                 Voice: +972-4-8228492
o...@actcom.co.il                  http://www.actcom.co.il/~oron
"Simplicity is prerequisite for reliability."
                        -- Edsger Wybe Dijkstra



_______________________________________________
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il

Reply via email to