RE: [PATCH] SMPP validity
"Oded Arbel" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
> -----Original Message----- > From: Vibhu Mohindra [mailto:[email protected]] > Sent: Thursday, August 22, 2002 2:03 PM > To: [email protected] > Subject: Re: [PATCH] SMPP validity > > > If the issue is solely with locatime_r(), but using localtime() and > the returned struct's tm_gmtoff is alright then let's do that rather No it's not. that was the point of my previous post. using tm_gmtoff is a much word portability braker then using localtime_r(). > > gmtime = gw_gmtime(time(NULL)); > > localtime = gw_localtime(time(NULL)); > > gwqdiff = ((localtime.tm_hour - gmtime.tm_hour) * 4) > > + ((localtime.tm_min - gmtime.tm_min) / 15); > > +gwqdiff = gwqdiff>12?gwqdiff-24:gwqdiff; > > I'm actually +6 UTC. However early in the morning it detected me as > -18 UTC. Not +18, so the algorithm given won't work in this case, or > for other cases east of Greenwich. Also it doesn't take into account I may be wrong (like I said - didn't test it), but in that case, it's pretty simple : add also - gwqdiff = gwqdiff<-12?gwqdiff+24:gwqdiff; or even remove the previous statement. > daylight savings (I admit I don't know much about daylight > savings, not > living in a country where they apply). I do, and don't know much about DST too - except that said method should also handle that, as gm_time is always non DST, and localtime() should return the current time stamp, DST applied. > In that case the calculation to get the difference in minutes may be > more like > > (local_tm.tm_year - gmt_tm.tm_year) * 365*24*60 + > (local_tm.tm_yday - gmt_tm.tm_yday) * 24*60 + > (local_tm.tm_hour - gmt_tm.tm_hour) * 60 + > (local_tm.tm_min - gmt_tm.tm_min ); Why would I want to handle years and days when I only need the hour difference ? -- Oded Arbel m-Wise mobile solutions [email protected] +972-9-9581711 (116) +972-67-340014 ::.. "Don't you go blame the movies Sid, movies don't make psychos, movies make psychos more creative" -- from "Scream"