From: <svn...@op...> - 2009-03-05 14:16:32
|
Author: bellmich Date: Thu Mar 5 15:16:21 2009 New Revision: 193 URL: http://libwbxml.opensync.org/changeset/193 Log: fixed timezone byte handling (e.g. A means UTC+1) Modified: wbxml2/trunk/src/wbxml_parser.c Modified: wbxml2/trunk/src/wbxml_parser.c ============================================================================== --- wbxml2/trunk/src/wbxml_parser.c Thu Mar 5 15:15:34 2009 (r192) +++ wbxml2/trunk/src/wbxml_parser.c Thu Mar 5 15:16:21 2009 (r193) @@ -2797,15 +2797,30 @@ /* Get Time Zone */ if (data_ptr[0] == 0) { + /* This is a bug in the WBXML document. + * If timezone UTC aka Zulu is used then a 'Z' must be set. + */ sprintf((WB_TINY *) result, "%s%s%sT%s%s%sZ", the_year, the_month, the_date, the_hour, the_minute, the_value ? the_second : ""); - } - else { + } else if (data_ptr[0] < 'A' || + data_ptr[0] > 'Z' || + data_ptr[0] == 'J') + { + /* This is a bug in the WBXML document. + * The timezone byte is set and wrong. + * There is no way to recover cleanly from this. + * Therefore no timezone is set. + */ sprintf((WB_TINY *) result, "%s%s%sT%s%s%s", the_year, the_month, the_date, the_hour, the_minute, the_value ? the_second : ""); } + else { + sprintf((WB_TINY *) result, + "%s%s%sT%s%s%s%c", + the_year, the_month, the_date, the_hour, the_minute, the_value ? the_second : "", data_ptr[0]); + } /* Reset buffer */ wbxml_buffer_delete(*data, 0, wbxml_buffer_len(*data)); |