diff options
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index e79ae109f..8980c702f 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -45,10 +45,11 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { "imei:" + "(\\d+)," + // IMEI "([^,]+)," + // Alarm - "(\\d{2})(\\d{2})(\\d{2})\\d+," + // Date + "(\\d{2})(\\d{2})(\\d{2})" + // Local Date + "(\\d{2})(\\d{2})," + // Local Time "[^,]*," + "[FL]," + // F - full / L - low - "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS) + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time UTC (HHMMSS.SSS) "([AV])," + // Validity "(\\d{2})(\\d{2}\\.\\d{4})," + // Latitude (DDMM.MMMM) "([NS])," + @@ -106,19 +107,34 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { extendedInfo.append("<alarm>"); extendedInfo.append(parser.group(index++)); extendedInfo.append("</alarm>"); - + // Date Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC")); time.clear(); time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++))); time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1); time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++))); + + int localHours = Integer.valueOf(parser.group(index++)); + int localMinutes = Integer.valueOf(parser.group(index++)); + + int utcHours = Integer.valueOf(parser.group(index++)); + int utcMinutes = Integer.valueOf(parser.group(index++)); // Time - time.set(Calendar.HOUR, Integer.valueOf(parser.group(index++))); - time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++))); + time.set(Calendar.HOUR, localHours); + time.set(Calendar.MINUTE, localMinutes); time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++))); time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++))); + + // Timezone calculation + int deltaMinutes = (localHours - utcHours) * 60 + localMinutes - utcMinutes; + if (deltaMinutes <= -12 * 60) { + deltaMinutes += 24 * 60; + } else if (deltaMinutes > 12) { + deltaMinutes -= 24 * 60; + } + time.add(Calendar.MINUTE, deltaMinutes); position.setTime(time.getTime()); // Validity |