Hi Alex,

How about this (see patch) - not sure if it's *nice* to use difftime but
it keeps it clean. 

Cheers,
Alan

ps. will look at have a relative vs absolute patch if 3.3 or >=3.4, etc

On Thu, 2004-11-18 at 03:23, Alexander Malysh wrote:
> Paul Keogh wrote:
> 
> > 
> >> 
> >> Btw. I don't know, why we calculate local <-> utc diff and
> >> for what it should be good? Patch just set timestamps in utc...
> >> 
> > 
> > Hmm, but does'nt the 3.4 spec say that the time stamp includes local
> > time value in quarter hours offset +/- from UTC. (section 7.1.1)
> > 
> > Your patch just sets the quarter hour offset to 0, so you effectively
> > ignore any local time offset ? Won't this confuse the SMSC ?
> 
> with my patch, we just tell SMSC that our localtime is utc time... how
> should this confuse SMSC? (just imagine your localtime really equal to utc)
> 
> > 
> > But, this time stuff makes me confused :-)
Index: gw/smsc/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v
retrieving revision 1.75
diff -u -r1.75 smsc_smpp.c
--- gw/smsc/smsc_smpp.c	21 Oct 2004 12:33:40 -0000	1.75
+++ gw/smsc/smsc_smpp.c	21 Nov 2004 23:22:51 -0000
@@ -690,8 +690,11 @@
         /* work out 1/4 hour difference between local time and UTC/GMT */
         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);
+
+	/* difftime returns the number of seconds elapsed.
+	 * convert to number of 1/4 hours
+	 */
+	gwqdiff = (int) (( difftime(gw_mktime(&localtime) , gw_mktime(&gmtime)) / 60 ) / 15 );
 
         if (gwqdiff >= 0) {
             relation_UTC_time = octstr_create("+");

Reply via email to