RE: [PATCH] timestamps
"Oded Arbel" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
My bad - sorry. date_convert_universal expects to get a time structure containing human readable values, not some "unix mktime mumbo jumbo" :-) here's the correct patch for smsc_at2.c agains the CVS Oded Arbel m-Wise Inc. [email protected] -- I used to have a handle on life; then it broke > -----Original Message----- > From: Oded Arbel > Sent: Thursday, February 07, 2002 6:48 PM > To: Kannel-devel (E-mail) > Subject: FW:[PATCH] timestamps, scripts and nokia 7110 > > > Don't send it to me - send it to the list :-) > > If I'm already forwarding stuff - I like the way Dennis fixed the time > reading from the PDU ( I know I should have fixed it earlier, > but I had > other things on my mind ;-), so I ported it to AT2 on the CVS. I also > changed the way he handles the time zone to get it to work. > Now decode_deliver decodes time correctly, but I still get bogus time > stamps with the messages - I guess it's date_convert_universal() > fault's. l'll look into it next. > All the patches below are Dennis Malmstrom's, except the > smsc_at2 patch > which is my own's. > I hadn't managed to apply all of Dennis' patches, them being against > 1.0.3 (Dennis - could you please try your changes on the CVS version ? > patche 1.0.3 doesn't really help the development much..) but > I like most > of his chnages.
smsc_at2.patch
(application/octet-stream, 2 KB)
diff -u gateway/gw/smsc_at2.c:1.1.1.1.2.30 gateway/gw/smsc_at2.c:1.1.1.1.2.37
--- gateway/gw/smsc_at2.c:1.1.1.1.2.30 Mon Jan 28 11:37:08 2002
+++ gateway/gw/smsc_at2.c Thu Feb 7 18:58:00 2002
@@ -1161,17 +1364,23 @@
/* DCS */
dcs = octstr_get_char(pdu, pos);
pos++;
/* get the timestamp */
- mtime.year = octstr_get_char(pdu, pos) + 1900; pos++;
- mtime.month = octstr_get_char(pdu, pos); pos++;
- mtime.day = octstr_get_char(pdu, pos); pos++;
- mtime.hour = octstr_get_char(pdu, pos); pos++;
- mtime.minute = octstr_get_char(pdu, pos); pos++;
- mtime.second = octstr_get_char(pdu, pos); pos++;
+ mtime.year = ( ( octstr_get_char(pdu, pos) & 15 ) * 10 ) + ( octstr_get_char(pdu, pos) >> 4 ) ; pos++;
+ mtime.year += (mtime.year < 70 ? 2000 : 1900);
+ mtime.month = ( ( octstr_get_char(pdu, pos) & 15 ) * 10 ) + ( octstr_get_char(pdu, pos) >> 4 ) ; pos++;
+ mtime.day = ( ( octstr_get_char(pdu, pos) & 15 ) * 10 ) + ( octstr_get_char(pdu, pos) >> 4 ); pos++;
+ mtime.hour = ( ( octstr_get_char(pdu, pos) & 15 ) * 10 ) + ( octstr_get_char(pdu, pos) >> 4 ); pos++;
+ mtime.minute = ( ( octstr_get_char(pdu, pos) & 15 ) * 10 ) + ( octstr_get_char(pdu, pos) >> 4 ); pos++;
+ mtime.second = ( ( octstr_get_char(pdu, pos) & 15 ) * 10 ) + ( octstr_get_char(pdu, pos) >> 4 ); pos++;
+
/* time zone: */
/* XXX handle negative time zones */
- mtime.hour += octstr_get_char(pdu, pos); pos++;
+ /* time zone is not "swapped nibble", with the MSB as the sign (1 is negative). the problem is that
+ +1 means that we have to substract 1 from the hour to get GMT. also remember that the time zone is measured
+ in quarters of the hour and not in full hours.
+ FIXME: we need to get the module of the division by 4 to the minute field */
+ mtime.hour += ((octstr_get_char(pdu, pos) >> 7) ? 1 : -1) * (octstr_get_char(pdu, pos) & 127) / 4; pos++;
stime = date_convert_universal(&mtime);
/* get data length */