[PATCH] smsc_smpp.c UTC time in 1/2 hours

Alex Judd <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hopefully the last time I have to correct/patch this bit of code for a 
while..

Alex



-- 
Alex Judd
http://www.skywire.co.uk
smsc_smpp.c.UTCtime.patch (text/plain, 1.9 KB)
Index: gw/smsc_smpp.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc_smpp.c,v
retrieving revision 1.65
diff -u -r1.65 smsc_smpp.c
--- gw/smsc_smpp.c	22 May 2002 12:08:10 -0000	1.65
+++ gw/smsc_smpp.c	24 May 2002 15:59:00 -0000
@@ -326,20 +326,19 @@
         /* work out 1/4 hour difference between local time and UTC/GMT */
         gmtime = gw_gmtime(time(NULL));
         localtime = gw_localtime(time(NULL));
-        if (localtime.tm_hour >= gmtime.tm_hour) {
+        gwqdiff = ((localtime.tm_hour - gmtime.tm_hour) * 4)
+                  + ((localtime.tm_min - gmtime.tm_min) / 15);
+        if (gwqdiff >= 0)
             relation_UTC_time = octstr_create("+");
-            gwqdiff = (localtime.tm_hour - gmtime.tm_hour) * 4;
-        } else {
+        else
             relation_UTC_time = octstr_create("-");
-            gwqdiff = (gmtime.tm_hour - localtime.tm_hour) * 4;
-        }
 
         if (msg->sms.validity) {
             tm = gw_localtime(time(NULL) + msg->sms.validity * 60);
             sprintf(buffer, "%02d%02d%02d%02d%02d%02d0%01d%02d%1s",
                     tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
                     tm.tm_hour, tm.tm_min, tm.tm_sec,
-                    0, gwqdiff, relation_UTC_time );
+                    0, gwqdiff, octstr_get_cstr(relation_UTC_time) );
             pdu->u.submit_sm.validity_period = octstr_create(buffer);
         }
 
@@ -348,7 +347,7 @@
             sprintf(buffer, "%02d%02d%02d%02d%02d%02d0%01d%02d%1s",
                     tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
                     tm.tm_hour, tm.tm_min, tm.tm_sec,
-                    0, gwqdiff, relation_UTC_time );
+                    0, gwqdiff, octstr_get_cstr(relation_UTC_time) );
             pdu->u.submit_sm.schedule_delivery_time = octstr_create(buffer);
         }
     }
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.