aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-11-23 13:37:36 -0800
committerAnton Tananaev <anton@traccar.org>2023-11-23 13:37:36 -0800
commitc4d2cf73f5a66759f7940ba4c11ec63976c05367 (patch)
tree4e537cfe62ca36a4154043a86dbe2ccc89ff349c /src
parente40b26908c32560c06c9fe47e9ab42f15054c586 (diff)
downloadtrackermap-server-c4d2cf73f5a66759f7940ba4c11ec63976c05367.tar.gz
trackermap-server-c4d2cf73f5a66759f7940ba4c11ec63976c05367.tar.bz2
trackermap-server-c4d2cf73f5a66759f7940ba4c11ec63976c05367.zip
Improve GT06 timezone handling
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
index cf7cd12d3..7ee47dd86 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -480,28 +480,21 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // type
deviceSession = getDeviceSession(channel, remoteAddress, imei);
- if (deviceSession != null && !deviceSession.contains(DeviceSession.KEY_TIMEZONE)) {
- deviceSession.set(DeviceSession.KEY_TIMEZONE, getTimeZone(deviceSession.getDeviceId()));
- }
-
- if (dataLength > 10) {
- int extensionBits = buf.readUnsignedShort();
- int hours = (extensionBits >> 4) / 100;
- int minutes = (extensionBits >> 4) % 100;
- int offset = (hours * 60 + minutes) * 60;
- if ((extensionBits & 0x8) != 0) {
- offset = -offset;
- }
- if (deviceSession != null) {
- TimeZone timeZone = deviceSession.get(DeviceSession.KEY_TIMEZONE);
- if (timeZone.getRawOffset() == 0) {
- timeZone.setRawOffset(offset * 1000);
- deviceSession.set(DeviceSession.KEY_TIMEZONE, timeZone);
+ if (deviceSession != null) {
+ TimeZone timeZone = getTimeZone(deviceSession.getDeviceId(), null);
+ if (timeZone == null && dataLength > 10) {
+ int extensionBits = buf.readUnsignedShort();
+ int hours = (extensionBits >> 4) / 100;
+ int minutes = (extensionBits >> 4) % 100;
+ int offset = (hours * 60 + minutes) * 60;
+ if ((extensionBits & 0x8) != 0) {
+ offset = -offset;
}
+ timeZone = TimeZone.getTimeZone("UTC");
+ timeZone.setRawOffset(offset * 1000);
}
- }
+ deviceSession.set(DeviceSession.KEY_TIMEZONE, timeZone);
- if (deviceSession != null) {
sendResponse(channel, false, type, buf.getShort(buf.writerIndex() - 6), null);
}