<div dir="ltr">thanks<br><br><div class="gmail_quote">On Sun, Mar 29, 2009 at 8:22 PM, Oron Peled <span dir="ltr"><<a href="mailto:oron@actcom.co.il">oron@actcom.co.il</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
(oops, the mailing list wasn't addressed in previous copy).<br>
<div><div></div><div class="h5"><br>
Erez:<br>
> struct tm time_str;<br>
> ...<br>
> int d=timegm(&time_str)-timelocal(&time_str);<br>
> printf("%d\n",d);<br>
><br>
><br>
> prints 7200 (which is 2*3600 -> two hours).<br>
><br>
><br>
> any idea ?<br>
> or in in other words, how the f@#k i get the offset from GMT c-code ?<br>
<br>
glibc-specific solution is easy:<br>
<br>
struct tm *tm;<br>
time_t t;<br>
<br>
t = time(NULL);<br>
tm = localtime(&t);<br>
printf("OFF=%ld\n", tm->tm_gmtoff);<br>
<br>
My system output:<br>
OFF=10800 # this is 3 hours<br>
<br>
<br>
--<br>
Oron Peled Voice: +972-4-8228492<br>
<a href="mailto:oron@actcom.co.il">oron@actcom.co.il</a> <a href="http://www.actcom.co.il/%7Eoron" target="_blank">http://www.actcom.co.il/~oron</a><br>
"Simplicity is prerequisite for reliability."<br>
-- Edsger Wybe Dijkstra<br>
<br>
<br>
</div></div></blockquote></div><br></div>