From 267c6e1651b6e0e91dd7c3463f86de929d7bc73c Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 9 Feb 2018 12:11:39 +0500 Subject: Implement unified device timezone handling --- src/org/traccar/protocol/UlbotechProtocolDecoder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/org/traccar/protocol/UlbotechProtocolDecoder.java') diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index f5ca9190b..5499518a1 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; -import org.traccar.Context; import org.traccar.DeviceSession; import org.traccar.helper.BitUtil; import org.traccar.helper.Checksum; @@ -39,11 +38,8 @@ import java.util.regex.Pattern; public class UlbotechProtocolDecoder extends BaseProtocolDecoder { - private final long timeZone; - public UlbotechProtocolDecoder(UlbotechProtocol protocol) { super(protocol); - timeZone = Context.getConfig().getInteger(getProtocolName() + ".timezone", 0); } private static final short DATA_GPS = 0x01; @@ -215,12 +211,16 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { return null; } + if (deviceSession.getTimeZone() == null) { + deviceSession.setTimeZone(getTimeZone(deviceSession.getDeviceId())); + } + Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); long seconds = buf.readUnsignedInt() & 0x7fffffffL; seconds += 946684800L; // 2000-01-01 00:00 - seconds -= timeZone; + seconds -= deviceSession.getTimeZone().getRawOffset() / 1000; Date time = new Date(seconds * 1000); boolean hasLocation = false; -- cgit v1.2.3