--- gateway/gw/smsc_at2.c	Thu Feb  7 18:18:49 2002
+++ patched/gw/smsc_at2.c	Thu Feb  7 18:28:17 2002
@@ -1163,15 +1163,20 @@
         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 ) + 100; pos++;
+	mtime.month  = ( ( octstr_get_char(pdu, pos) & 15 ) * 10 ) + ( octstr_get_char(pdu, pos) >> 4 ) - 1; 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 */
