time zone problems
Erez D
erez0001 at gmail.com
Mon Mar 30 10:59:44 IDT 2009
thanks
On Sun, Mar 29, 2009 at 8:22 PM, Oron Peled <oron at actcom.co.il> wrote:
> (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
> oron at actcom.co.il http://www.actcom.co.il/~oron<http://www.actcom.co.il/%7Eoron>
> "Simplicity is prerequisite for reliability."
> -- Edsger Wybe Dijkstra
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20090330/20c45c00/attachment.html>
More information about the Linux-il
mailing list