From a9d67eb0bf43be5c4444def20a52f3160ddab623 Mon Sep 17 00:00:00 2001 From: buzzcode2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Wed, 19 Mar 2025 14:26:04 +0000 Subject: [PATCH] feat: Standard time conversion --- scripts/timeprocessor.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 scripts/timeprocessor.js diff --git a/scripts/timeprocessor.js b/scripts/timeprocessor.js new file mode 100644 index 0000000..b951ccd --- /dev/null +++ b/scripts/timeprocessor.js @@ -0,0 +1,18 @@ + +/* Process the conversion of times. */ +class TimeProcessor { + static convert(DATE) { + try { + DATE = (DATE != null && isNaN(Number(DATE))) ? DATE : Number(DATE); + + let TIME = new Date(DATE); + if (TIME == "Invalid Date") {throw EvalError}; + + return ({"unix": TIME.getTime(), "utc": TIME.toUTCString()}); + } catch(err) { + throw(err); + } + } +} + +module.exports = {TimeProcessor}; \ No newline at end of file