mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for Shelly
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
751bbf7495
commit
96b5ad2e55
@ -345,7 +345,6 @@ public class ShellyManagerPage {
|
||||
value = dateTimeState.format(null).replace('T', ' ').replace('-', '/');
|
||||
break;
|
||||
default:
|
||||
value = getTimestamp(dateTimeState);
|
||||
value = dateTimeState.format(null).replace('T', ' ').replace('-', '/');
|
||||
}
|
||||
} else {
|
||||
|
@ -304,17 +304,13 @@ public class ShellyUtils {
|
||||
ZoneId zoneId = !zone.isEmpty() ? ZoneId.of(zone) : ZoneId.systemDefault();
|
||||
ZonedDateTime zdt = LocalDateTime.now().atZone(zoneId);
|
||||
int delta = zdt.getOffset().getTotalSeconds();
|
||||
return new DateTimeType(ZonedDateTime.ofInstant(Instant.ofEpochSecond(timestamp - delta), zoneId));
|
||||
return new DateTimeType(Instant.ofEpochSecond(timestamp - delta));
|
||||
} catch (DateTimeException e) {
|
||||
// Unable to convert device's timezone, use system one
|
||||
return getTimestamp();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTimestamp(DateTimeType dt) {
|
||||
return dt.getZonedDateTime().toString().replace('T', ' ').replace('-', '/');
|
||||
}
|
||||
|
||||
public static String convertTimestamp(long ts) {
|
||||
if (ts == 0) {
|
||||
return "";
|
||||
|
Loading…
Reference in New Issue
Block a user