Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

FIX: offset is automatically calculated by Date function (#995)

Alexandru Bogdan8f375566b893
diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.ts
index 97a312626..3abd7de7a 100644
--- a/ui/component/core/src/util.ts
+++ b/ui/component/core/src/util.ts
@@ -633,8 +633,7 @@ export function getValueAsString(value: any, formatProvider: () => ValueFormat |
value = !!value;
} else if (format.asDate) {
// Assume UNIX timestamp in ms
- const offset = (new Date()).getTimezoneOffset() * 60000;
- value = new Date(value - offset);
+ value = new Date(value);
}
} else if (typeof(value) === "boolean" && format.asNumber) {
value = value ? 1 : 0;
diff --git a/ui/component/or-mwc-components/src/or-mwc-input.ts b/ui/component/or-mwc-components/src/or-mwc-input.ts
index 366f9ea9c..96f1305f4 100644
--- a/ui/component/or-mwc-components/src/or-mwc-input.ts
+++ b/ui/component/or-mwc-components/src/or-mwc-input.ts
@@ -1714,9 +1714,7 @@ export class OrMwcInput extends LitElement {
newValue = null;
} else {
try {
- const date = Date.parse(newValue);
- const offset = (new Date()).getTimezoneOffset() * 60000;
- newValue = date + offset;
+ newValue = Date.parse(newValue);
} catch (e) {
newValue = this.value;
errorMsg = i18next.t("validation.invalidDate");