1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

ID115: Fix date calculation

This commit is contained in:
Vadim Kaushan 2018-07-12 15:56:52 +03:00
parent 814ca76733
commit 8a0263d3ff

View File

@ -10,6 +10,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.UUID; import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Constants; import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Constants;
@ -224,7 +225,7 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
} }
ID115Support setTime(TransactionBuilder builder) { ID115Support setTime(TransactionBuilder builder) {
Calendar c = GregorianCalendar.getInstance(); Calendar c = Calendar.getInstance(TimeZone.getDefault());
int day = c.get(Calendar.DAY_OF_WEEK); int day = c.get(Calendar.DAY_OF_WEEK);
@ -235,11 +236,12 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
dayOfWeek = (byte)(day - 2); dayOfWeek = (byte)(day - 2);
} }
// TODO: set year int year = c.get(Calendar.YEAR);
builder.write(normalWriteCharacteristic, new byte[] { builder.write(normalWriteCharacteristic, new byte[] {
ID115Constants.CMD_ID_SETTINGS, ID115Constants.CMD_KEY_SET_TIME, ID115Constants.CMD_ID_SETTINGS, ID115Constants.CMD_KEY_SET_TIME,
0, 0, (byte)(year & 0xff),
(byte)c.get(Calendar.MONTH), (byte)(year >> 8),
(byte)(1 + c.get(Calendar.MONTH)),
(byte)c.get(Calendar.DAY_OF_MONTH), (byte)c.get(Calendar.DAY_OF_MONTH),
(byte)c.get(Calendar.HOUR_OF_DAY), (byte)c.get(Calendar.HOUR_OF_DAY),
(byte)c.get(Calendar.MINUTE), (byte)c.get(Calendar.MINUTE),