mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for Mercedes Me
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
2f33a2d1ae
commit
164e333a40
@ -14,6 +14,7 @@ package org.openhab.binding.mercedesme.internal.handler;
|
|||||||
|
|
||||||
import static org.openhab.binding.mercedesme.internal.Constants.*;
|
import static org.openhab.binding.mercedesme.internal.Constants.*;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -954,7 +955,7 @@ public class VehicleHandler extends BaseThingHandler {
|
|||||||
if (vas != null && !Utils.isNil(vas)) {
|
if (vas != null && !Utils.isNil(vas)) {
|
||||||
// proto weekday starts with MONDAY=0, java ZonedDateTime starts with MONDAY=1
|
// proto weekday starts with MONDAY=0, java ZonedDateTime starts with MONDAY=1
|
||||||
long estimatedWeekday = Utils.getInt(vas) + 1;
|
long estimatedWeekday = Utils.getInt(vas) + 1;
|
||||||
ZonedDateTime storedZdt = endDateTimeType.getZonedDateTime();
|
ZonedDateTime storedZdt = endDateTimeType.getZonedDateTime(ZoneId.systemDefault());
|
||||||
long storedWeekday = storedZdt.getDayOfWeek().getValue();
|
long storedWeekday = storedZdt.getDayOfWeek().getValue();
|
||||||
// check if estimated weekday is smaller than stored
|
// check if estimated weekday is smaller than stored
|
||||||
// estimation Monday=1 vs. stored Saturday=6 => (7+1)-6=2 days ahead
|
// estimation Monday=1 vs. stored Saturday=6 => (7+1)-6=2 days ahead
|
||||||
|
@ -107,8 +107,7 @@ public class Utils {
|
|||||||
* @return openHAB DateTimeType according to configured TimeZone
|
* @return openHAB DateTimeType according to configured TimeZone
|
||||||
*/
|
*/
|
||||||
public static DateTimeType getDateTimeType(long ms) {
|
public static DateTimeType getDateTimeType(long ms) {
|
||||||
Instant timestamp = Instant.ofEpochMilli(ms);
|
return new DateTimeType(Instant.ofEpochMilli(ms));
|
||||||
return new DateTimeType(timestamp.atZone(timeZoneProvider.getTimeZone()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user