Fix issues caused by invalid xsd:dateTime values

Invalid dateTime strings were saved in the DB as NaN causing uncaught
exception in CSV download.
This commit is contained in:
Zaid Abdulla committed 2022-03-11 11:42:10 -08:00
1 parent 2b37f11e2e
commit 4b533d0aad
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -148,7 +148,7 @@ export async function fetchDevice(
if (obj["_value"] != null) {
attrs.value = [obj["_timestamp"] || 1, [obj["_value"], obj["_type"]]];
if (obj["_type"] === "xsd:dateTime")
if (obj["_type"] === "xsd:dateTime" && obj["_value"] instanceof Date)
attrs.value[1][0] = +attrs.value[1][0];
obj["_object"] = false;
+1 -1
View File
@@ -125,7 +125,7 @@ router.get(`/devices/:id.csv`, async (ctx) => {
new Date(p.objectTimestamp).toJSON(),
p.writable,
new Date(p.writableTimestamp).toJSON(),
`"${value.toString().replace(/"/g, '""')}"`,
`"${String(value).replace(/"/g, '""')}"`,
type,
new Date(p.valueTimestamp).toJSON(),
p.notification,