From 0ba7f33f29bb8adfd235ebda9a8e35c5de836cef Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:39:34 +0200 Subject: [PATCH] Change lightning event to provide timestamp and time (#47) --- scripts/uplink_formatter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/uplink_formatter.js b/scripts/uplink_formatter.js index 1b18b75..a7172ac 100644 --- a/scripts/uplink_formatter.js +++ b/scripts/uplink_formatter.js @@ -118,6 +118,7 @@ // 20240530 Added SKIP_INVALID_SIGNALS // Added BLE signals to decoder // 20240531 Fixed handling of arrays in decoder() +// 20240601 Change lightning event to provide timestamp and time // // ToDo: // - @@ -177,7 +178,10 @@ function decoder(bytes, port) { if (bytes.length !== unixtime.BYTES) { throw new Error('Unix time must have exactly 4 bytes'); } - return bytesToInt(bytes); + dateObj = new Date(bytesToInt(bytes) * 1000); + let time = dateObj.toISOString(); + let timestamp = bytesToInt(bytes); + return { time: time, timestamp: timestamp }; }; unixtime.BYTES = 4;