1
0
mirror of synced 2025-01-19 16:08:44 +01:00

Create DateTime.js

This commit is contained in:
bwhitn 2017-06-08 08:28:21 -07:00 committed by GitHub
parent 96ec3a869b
commit a144f65dcf

View File

@ -1,4 +1,4 @@
import Decimal from '../lib/decimal.min.js'; import Decimal from "../lib/decimal.min.js";
/** /**
* Date and time operations. * Date and time operations.
@ -90,7 +90,7 @@ const DateTime = {
runFromFiletimeToUnix: function(input, args) { runFromFiletimeToUnix: function(input, args) {
input = new Decimal(input); input = new Decimal(input);
input = input.sub(116444736000000000).div(10000000); input = input.sub(116444736000000000).div(10000000);
if(input.gte(0) && input.lt(Math.pow(2,31))){ if (input.gte(0) && input.lt(Math.pow(2, 31))){
return input.toString(); return input.toString();
} else { } else {
throw "Date " + input + " is not a valid date"; throw "Date " + input + " is not a valid date";
@ -107,7 +107,7 @@ const DateTime = {
*/ */
runToFiletimeFromUnix: function(input, args) { runToFiletimeFromUnix: function(input, args) {
input = new Decimal(input); input = new Decimal(input);
if(input.gte(0) && input.lt(Math.pow(2,31))){ if (input.gte(0) && input.lt(Math.pow(2, 31))){
return input.mul(10000000).add(116444736000000000).toHex(); return input.mul(10000000).add(116444736000000000).toHex();
} else { } else {
throw "Date " + input + " is not a valid date"; throw "Date " + input + " is not a valid date";