mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-06-02 11:26:09 +02:00
7ee82e6afa
note: only weather message definition and data tested so far also enable weather support for Instinct 2S and vivomove style also cleanup some unused constants that have been migrated to new enums in GFDIMessage additionally switch to new local implementation of GarminTimeUtils with needed methods
30 lines
905 B
Java
30 lines
905 B
Java
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin;
|
|
|
|
import org.threeten.bp.Instant;
|
|
import org.threeten.bp.ZoneId;
|
|
|
|
public class GarminTimeUtils {
|
|
|
|
private static final int GARMIN_TIME_EPOCH = 631065600;
|
|
|
|
public static int unixTimeToGarminTimestamp(int unixTime) {
|
|
return unixTime - GARMIN_TIME_EPOCH;
|
|
}
|
|
|
|
public static int javaMillisToGarminTimestamp(long millis) {
|
|
return (int) (millis / 1000) - GARMIN_TIME_EPOCH;
|
|
}
|
|
|
|
public static long garminTimestampToJavaMillis(int timestamp) {
|
|
return (timestamp + GARMIN_TIME_EPOCH) * 1000L;
|
|
}
|
|
|
|
public static int garminTimestampToUnixTime(int timestamp) {
|
|
return timestamp + GARMIN_TIME_EPOCH;
|
|
}
|
|
|
|
public static int unixTimeToGarminDayOfWeek(int unixTime) {
|
|
return (Instant.ofEpochSecond(unixTime).atZone(ZoneId.systemDefault()).getDayOfWeek().getValue() % 7);
|
|
}
|
|
}
|