From f6c8c9e76ce863355aeda8fc1ff93c411736a7f0 Mon Sep 17 00:00:00 2001 From: n1073645 Date: Mon, 24 Aug 2020 10:39:18 +0100 Subject: [PATCH] swap endianness argument added to Windows Filetime To Unix Timestamp --- .../WindowsFiletimeToUNIXTimestamp.mjs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/operations/WindowsFiletimeToUNIXTimestamp.mjs b/src/core/operations/WindowsFiletimeToUNIXTimestamp.mjs index 57d1e477..32c272f9 100644 --- a/src/core/operations/WindowsFiletimeToUNIXTimestamp.mjs +++ b/src/core/operations/WindowsFiletimeToUNIXTimestamp.mjs @@ -35,6 +35,11 @@ class WindowsFiletimeToUNIXTimestamp extends Operation { "name": "Input format", "type": "option", "value": ["Decimal", "Hex"] + }, + { + "name": "Swap Endianness", + "type": "boolean", + "value": false } ]; } @@ -45,7 +50,16 @@ class WindowsFiletimeToUNIXTimestamp extends Operation { * @returns {string} */ run(input, args) { - const [units, format] = args; + const [units, format, swapEndianness] = args; + + if (swapEndianness) { + let result = ""; + for (let i = input.length - 2; i >= 0; i -= 2) { + result += input.charAt(i); + result += input.charAt(i + 1); + } + input = result; + } if (!input) return "";