{"record":{"id":"f4a82f50fdb32fb2","repo":"gchq/CyberChef","slug":"unrecognised-unit-f4a82f","errorCode":null,"errorMessage":"Unrecognised unit","messagePattern":"Unrecognised unit","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/UNIXTimestampToWindowsFiletime.mjs","lineNumber":63,"sourceCode":"     * @returns {string}\n     */\n    run(input, args) {\n        const [units, format] = args;\n\n        if (!input) return \"\";\n\n        input = new BigNumber(input);\n\n        if (units === \"Seconds (s)\") {\n            input = input.multipliedBy(new BigNumber(\"10000000\"));\n        } else if (units === \"Milliseconds (ms)\") {\n            input = input.multipliedBy(new BigNumber(\"10000\"));\n        } else if (units === \"Microseconds (μs)\") {\n            input = input.multipliedBy(new BigNumber(\"10\"));\n        } else if (units === \"Nanoseconds (ns)\") {\n            input = input.dividedBy(new BigNumber(\"100\"));\n        } else {\n            throw new OperationError(\"Unrecognised unit\");\n        }\n\n        input = input.plus(new BigNumber(\"116444736000000000\"));\n\n        let result;\n        if (format.startsWith(\"Hex\")) {\n            result = input.toString(16);\n        } else {\n            result = input.toFixed();\n        }\n\n        if (format === \"Hex (little endian)\") {\n            // Swap endianness\n            let flipped = \"\";\n            for (let i = result.length - 2; i >= 0; i -= 2) {\n                flipped += result.charAt(i);\n                flipped += result.charAt(i + 1);\n            }","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/UNIXTimestampToWindowsFiletime.mjs#L45-L81","documentation":"Thrown by 'UNIX Timestamp to Windows Filetime' when the units argument matches none of 'Seconds (s)', 'Milliseconds (ms)', 'Microseconds (us)', or 'Nanoseconds (ns)'. The units string is compared exactly; any other value falls through to the else branch.","triggerScenarios":"Passing a units value that is not one of the four exact option strings, e.g. a lowercased 'seconds (s)', 'Microseconds (µs)' with the wrong micro sign, or undefined. Reachable via the Node API or a hand-edited recipe since the UI restricts to the dropdown.","commonSituations":"Programmatically building a recipe with a units string copied from docs that uses a different micro-character (μ U+03BC vs µ U+00B5), or localised/case-altered labels.","solutions":["Use one of the exact option strings: 'Seconds (s)', 'Milliseconds (ms)', 'Microseconds (μs)', or 'Nanoseconds (ns)'.","Pull the allowed values from the operation's args definition instead of hardcoding.","Watch for look-alike micro signs (μ vs µ) when copy-pasting."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const UNITS = [\"Seconds (s)\", \"Milliseconds (ms)\", \"Microseconds (\\u03bcs)\", \"Nanoseconds (ns)\"];\nif (!UNITS.includes(units)) {\n  throw new Error(`Unrecognised unit '${units}'`);\n}","typeGuard":"function isValidFiletimeUnit(u) { return [\"Seconds (s)\",\"Milliseconds (ms)\",\"Microseconds (\\u03bcs)\",\"Nanoseconds (ns)\"].includes(u); }","tryCatchPattern":null,"preventionTips":["Source unit strings from the operation's args definition.","Watch for look-alike micro characters when copy-pasting."],"tags":["datetime","filetime","validation","argument-error","recipe"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}