diff --git a/hogvm/__tests__/__snapshots__/catch.js b/hogvm/__tests__/__snapshots__/catch.js index 5b4d790238ebd..79b63a2cb64e3 100644 --- a/hogvm/__tests__/__snapshots__/catch.js +++ b/hogvm/__tests__/__snapshots__/catch.js @@ -9,7 +9,7 @@ function __getProperty(objectOrArray, key, nullish) { } } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) } diff --git a/hogvm/__tests__/__snapshots__/catch2.js b/hogvm/__tests__/__snapshots__/catch2.js index d075a1b41b0ab..9f382cba0bbd8 100644 --- a/hogvm/__tests__/__snapshots__/catch2.js +++ b/hogvm/__tests__/__snapshots__/catch2.js @@ -9,7 +9,7 @@ function __getProperty(objectOrArray, key, nullish) { } } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) } diff --git a/hogvm/__tests__/__snapshots__/date.js b/hogvm/__tests__/__snapshots__/date.js index cd56e05ea4fc0..66b2b87239e78 100644 --- a/hogvm/__tests__/__snapshots__/date.js +++ b/hogvm/__tests__/__snapshots__/date.js @@ -3,11 +3,11 @@ function toUnixTimestamp (input, zone) { return __toUnixTimestamp(input, zone) } function toTimeZone (input, zone) { return __toTimeZone(input, zone) } function toString (value) { return __STLToString(value) } function toInt(value) { - if (__isHogDateTime(value)) { return Math.floor(value.dt); } + if (__isHogDateTime(value)) { return Math.floor(value.dt); } else if (__isHogDate(value)) { const date = new Date(Date.UTC(value.year, value.month - 1, value.day)); const epoch = new Date(Date.UTC(1970, 0, 1)); const diffInDays = Math.floor((date - epoch) / (1000 * 60 * 60 * 24)); return diffInDays; } return !isNaN(parseInt(value)) ? parseInt(value) : null; } function toFloat(value) { - if (__isHogDateTime(value)) { return value.dt; } + if (__isHogDateTime(value)) { return value.dt; } else if (__isHogDate(value)) { const date = new Date(Date.UTC(value.year, value.month - 1, value.day)); const epoch = new Date(Date.UTC(1970, 0, 1)); const diffInDays = (date - epoch) / (1000 * 60 * 60 * 24); return diffInDays; } return !isNaN(parseFloat(value)) ? parseFloat(value) : null; } function toDateTime (input, zone) { return __toDateTime(input, zone) } @@ -41,7 +41,7 @@ function __toHogDateTime(timestamp, zone) { } return { __hogDateTime__: true, dt: timestamp, zone: zone || 'UTC' }; } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) } diff --git a/hogvm/__tests__/__snapshots__/dateFormat.js b/hogvm/__tests__/__snapshots__/dateFormat.js index 4afe34ca1cce2..9b5c7d6d05235 100644 --- a/hogvm/__tests__/__snapshots__/dateFormat.js +++ b/hogvm/__tests__/__snapshots__/dateFormat.js @@ -160,7 +160,7 @@ function __formatDateTime(input, format, zone) { return result; } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) } diff --git a/hogvm/__tests__/__snapshots__/exceptions.js b/hogvm/__tests__/__snapshots__/exceptions.js index 75ccf5020d52c..7acbcc1ceb29e 100644 --- a/hogvm/__tests__/__snapshots__/exceptions.js +++ b/hogvm/__tests__/__snapshots__/exceptions.js @@ -1,7 +1,7 @@ function print (...args) { console.log(...args.map(__printHogStringOutput)) } function concat (...args) { return args.map((arg) => (arg === null ? '' : __STLToString(arg))).join('') } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) } diff --git a/hogvm/__tests__/__snapshots__/json.js b/hogvm/__tests__/__snapshots__/json.js index 4d08d40f2cc90..4b4ea461662b2 100644 --- a/hogvm/__tests__/__snapshots__/json.js +++ b/hogvm/__tests__/__snapshots__/json.js @@ -29,7 +29,7 @@ function jsonStringify (value, spacing) { } function jsonParse (str) { function convert(x) { - if (Array.isArray(x)) { return x.map(convert) } + if (Array.isArray(x)) { return x.map(convert) } else if (typeof x === 'object' && x !== null) { if (x.__hogDateTime__) { return __toHogDateTime(x.dt, x.zone) } else if (x.__hogDate__) { return __toHogDate(x.year, x.month, x.day) diff --git a/hogvm/__tests__/__snapshots__/lambdas.js b/hogvm/__tests__/__snapshots__/lambdas.js index 58fb76fbee8c3..0560b6d65d4fd 100644 --- a/hogvm/__tests__/__snapshots__/lambdas.js +++ b/hogvm/__tests__/__snapshots__/lambdas.js @@ -29,7 +29,7 @@ function jsonStringify (value, spacing) { } function jsonParse (str) { function convert(x) { - if (Array.isArray(x)) { return x.map(convert) } + if (Array.isArray(x)) { return x.map(convert) } else if (typeof x === 'object' && x !== null) { if (x.__hogDateTime__) { return __toHogDateTime(x.dt, x.zone) } else if (x.__hogDate__) { return __toHogDate(x.year, x.month, x.day) diff --git a/hogvm/__tests__/__snapshots__/mandelbrot.js b/hogvm/__tests__/__snapshots__/mandelbrot.js index 9824fdfe94646..01591b130016c 100644 --- a/hogvm/__tests__/__snapshots__/mandelbrot.js +++ b/hogvm/__tests__/__snapshots__/mandelbrot.js @@ -1,7 +1,7 @@ function print (...args) { console.log(...args.map(__printHogStringOutput)) } function concat (...args) { return args.map((arg) => (arg === null ? '' : __STLToString(arg))).join('') } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) } diff --git a/hogvm/__tests__/__snapshots__/operations.js b/hogvm/__tests__/__snapshots__/operations.js index 7525e642c918f..9cb5513d3afbf 100644 --- a/hogvm/__tests__/__snapshots__/operations.js +++ b/hogvm/__tests__/__snapshots__/operations.js @@ -1,11 +1,11 @@ function toUUID (value) { return __STLToString(value) } function toString (value) { return __STLToString(value) } function toInt(value) { - if (__isHogDateTime(value)) { return Math.floor(value.dt); } + if (__isHogDateTime(value)) { return Math.floor(value.dt); } else if (__isHogDate(value)) { const date = new Date(Date.UTC(value.year, value.month - 1, value.day)); const epoch = new Date(Date.UTC(1970, 0, 1)); const diffInDays = Math.floor((date - epoch) / (1000 * 60 * 60 * 24)); return diffInDays; } return !isNaN(parseInt(value)) ? parseInt(value) : null; } function toFloat(value) { - if (__isHogDateTime(value)) { return value.dt; } + if (__isHogDateTime(value)) { return value.dt; } else if (__isHogDate(value)) { const date = new Date(Date.UTC(value.year, value.month - 1, value.day)); const epoch = new Date(Date.UTC(1970, 0, 1)); const diffInDays = (date - epoch) / (1000 * 60 * 60 * 24); return diffInDays; } return !isNaN(parseFloat(value)) ? parseFloat(value) : null; } function print (...args) { console.log(...args.map(__printHogStringOutput)) } @@ -53,7 +53,7 @@ function __like(str, pattern, caseInsensitive = false) { return new RegExp(pattern).test(str) } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) } diff --git a/hogvm/__tests__/__snapshots__/printLoops.js b/hogvm/__tests__/__snapshots__/printLoops.js index e197e0bf75164..c02d521f73bca 100644 --- a/hogvm/__tests__/__snapshots__/printLoops.js +++ b/hogvm/__tests__/__snapshots__/printLoops.js @@ -29,7 +29,7 @@ function jsonStringify (value, spacing) { } function jsonParse (str) { function convert(x) { - if (Array.isArray(x)) { return x.map(convert) } + if (Array.isArray(x)) { return x.map(convert) } else if (typeof x === 'object' && x !== null) { if (x.__hogDateTime__) { return __toHogDateTime(x.dt, x.zone) } else if (x.__hogDate__) { return __toHogDate(x.year, x.month, x.day) @@ -66,7 +66,7 @@ function __newHogError(type, message, payload) { return error } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) } diff --git a/hogvm/__tests__/__snapshots__/printLoops2.js b/hogvm/__tests__/__snapshots__/printLoops2.js index 9a3d7e17fa901..a588347b609d2 100644 --- a/hogvm/__tests__/__snapshots__/printLoops2.js +++ b/hogvm/__tests__/__snapshots__/printLoops2.js @@ -29,7 +29,7 @@ function jsonStringify (value, spacing) { } function jsonParse (str) { function convert(x) { - if (Array.isArray(x)) { return x.map(convert) } + if (Array.isArray(x)) { return x.map(convert) } else if (typeof x === 'object' && x !== null) { if (x.__hogDateTime__) { return __toHogDateTime(x.dt, x.zone) } else if (x.__hogDate__) { return __toHogDate(x.year, x.month, x.day) @@ -66,7 +66,7 @@ function __newHogError(type, message, payload) { return error } function __STLToString(arg) { - if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } + if (arg && __isHogDate(arg)) { return `${arg.year}-${arg.month.toString().padStart(2, '0')}-${arg.day.toString().padStart(2, '0')}`; } else if (arg && __isHogDateTime(arg)) { return __DateTimeToString(arg); } return __printHogStringOutput(arg); } function __printHogStringOutput(obj) { if (typeof obj === 'string') { return obj } return __printHogValue(obj) }