From c0142adba902e42c9194a320c5f15faed3b7cd4d Mon Sep 17 00:00:00 2001 From: Bwhit1 Date: Mon, 12 Jun 2017 15:39:54 -0400 Subject: [PATCH] changed error to conform with the rest of the functions and simplified repetative math. --- src/core/operations/DateTime.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/operations/DateTime.js b/src/core/operations/DateTime.js index bac9b861..a7a3c483 100755 --- a/src/core/operations/DateTime.js +++ b/src/core/operations/DateTime.js @@ -89,8 +89,8 @@ const DateTime = { * @returns {string} */ runFromFiletimeToUnix: function(input, args) { - let units = args[0], offset = new BigInteger("116444736000000000"); - input = new BigInteger(input).subtract(offset); + let units = args[0]; + input = new BigInteger(input).subtract(new BigInteger("116444736000000000")); if (units === "Seconds (s)"){ input = input.divide(new BigInteger("10000000")); } else if (units === "Milliseconds (ms)") { @@ -100,7 +100,7 @@ const DateTime = { } else if (units === "Nanoseconds (ns)") { input = input.multiply(new BigInteger("100")); } else { - throw "The value " + input + " cannot be expressed as a UNIX timestamp."; + throw "Unrecognised unit"; } return input.toString(); }, @@ -115,20 +115,20 @@ const DateTime = { * @returns {string} */ runToFiletimeFromUnix: function(input, args) { - let units = args[0], offset = new BigInteger("116444736000000000"); + let units = args[0]; input = new BigInteger(input); if (units === "Seconds (s)"){ - input = input.multiply(new BigInteger("10000000")).add(offset); + input = input.multiply(new BigInteger("10000000")); } else if (units === "Milliseconds (ms)") { - input = input.multiply(new BigInteger("10000")).add(offset); + input = input.multiply(new BigInteger("10000")); } else if (units === "Microseconds (μs)") { - input = input.multiply(new BigInteger("10")).add(offset); + input = input.multiply(new BigInteger("10")); } else if (units === "Nanoseconds (ns)") { - input = input.divide(new BigInteger("100")).add(offset); + input = input.divide(new BigInteger("100")); } else { - throw "The value " + input + " cannot be expressed as a UNIX timestamp."; + throw "Unrecognised unit"; } - return input.toString(); + return input.add(new BigInteger("116444736000000000")).toString(); },