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]]

> > Why would I want to handle years and days when I only need the hour
> > difference ?
> 
> OK, here's why looking only at hours and minutes isn't 
> enough. A country
> which is +12 GMT will be identified at 11am as being -12 GMT. 
> Past noon
> it will be correctly identified as +12 GMT. Our normalising version
> which adds/subtracts 24 hours doesn't work for such a place.

Ahmm... GMT+12 and GMT-12 is the same timezone. it's just a matter of
how you look at it. both are valid. it's like saying GMT+0 and GMT-0 are
different time zones.

> I believe that it is not a matter of correcting the 
> normalising algorithm
> proposed. In fact, this cannot be corrected only by looking at hours
> and minutes. So you get into the process of comparing days of the year
> as well. That leads to having to compare years as well to account for
> wrap arounds on New Year's. That leads to accounting for leap years...

No - it's not. you can account only for hours and minutes and then
handle a few special cases (one or two).

for the sake of portability, minimize your use of library calls - use
the only the most necessary and implement the algorithms yourself - the
library call doesn't do much more then what we are doing.

For setting SMPP validity we do not need to have a 100% correct
implementation - most SMSCs that I used don't handle time stamps very
well anyway - you just need an implementation that works in a
predictable way.

the following code seems to me to be good enough :
<snip>
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>48?gwqdiff-96):(gwqdiff<=-48?gwqdiff+96:gwqdiff)
<snip>

This will normalize anything to the range GMT-11 - GMT+12, or you can
have it normalize to GMT-12 - GMT+11 by changing '<=' to '<' and '>' to
'>='.

--
Oded Arbel
m-Wise mobile solutions
[email protected]

+972-9-9581711 (116)
+972-67-340014

::..
10 SIN
20 GOTO HELL
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.