@qrvey/utils 1.6.0-3 → 1.6.0-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/column_format/helpers/defineTableChartFormat.js +12 -0
- package/dist/cjs/dates/helpers/adjustTimezone.js +6 -0
- package/dist/cjs/dates/helpers/isValidPotentialDate.js +1 -1
- package/dist/cjs/format/definition.js +1 -0
- package/dist/column_format/helpers/defineTableChartFormat.js +12 -0
- package/dist/dates/helpers/adjustTimezone.js +6 -0
- package/dist/dates/helpers/isValidPotentialDate.js +1 -1
- package/dist/format/definition.js +1 -0
- package/package.json +1 -1
|
@@ -58,6 +58,18 @@ const defineTableChartFormat = (column, settings) => {
|
|
|
58
58
|
return selectedFormat;
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
+
case COLUMN_1.COLUMN.TIME: {
|
|
62
|
+
if (noFormatSupported)
|
|
63
|
+
return STRING_FORMAT_1.STRING_FORMAT.NONE;
|
|
64
|
+
if (selectedFormat)
|
|
65
|
+
return selectedFormat;
|
|
66
|
+
if (hasDefaultFormat) {
|
|
67
|
+
const columnDefaultFormat = defaultFormat ||
|
|
68
|
+
outputFormat || { type: "TIME", format: "HH:mm:ss" };
|
|
69
|
+
return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, columnDefaultFormat), type: "TIME" });
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
61
73
|
case COLUMN_1.COLUMN.NUMERIC:
|
|
62
74
|
case COLUMN_1.COLUMN.RATING:
|
|
63
75
|
case COLUMN_1.COLUMN.SLIDEBAR: {
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.adjustTimezone = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const isValidPotentialDate_1 = require("./isValidPotentialDate");
|
|
6
|
+
const validateDate_1 = require("./validateDate");
|
|
4
7
|
/**
|
|
5
8
|
* Adjusts a Date with the UTC-0 Timezone.
|
|
6
9
|
* @param date String, object or millisencond number of the date
|
|
7
10
|
* @returns updated Date object
|
|
8
11
|
*/
|
|
9
12
|
function adjustTimezone(date) {
|
|
13
|
+
if (!(0, isValidPotentialDate_1.isValidPotentialDate)(date) ||
|
|
14
|
+
(typeof date === "string" && !(0, validateDate_1.validateDate)(date, constants_1.DATE_FORMAT.DAY)))
|
|
15
|
+
return date;
|
|
10
16
|
const dt = new Date(date.valueOf());
|
|
11
17
|
return new Date(+dt + dt.getTimezoneOffset() * 1000 * 60);
|
|
12
18
|
}
|
|
@@ -11,7 +11,7 @@ const isTokenLabel_1 = require("../../tokens/isTokenLabel");
|
|
|
11
11
|
function isValidPotentialDate(date) {
|
|
12
12
|
return (!(0, isEmpty_1.isEmpty)(date) &&
|
|
13
13
|
!(0, isTokenLabel_1.isTokenLabel)(date) &&
|
|
14
|
-
(date instanceof Date ||
|
|
14
|
+
((date instanceof Date && !isNaN(date)) ||
|
|
15
15
|
typeof date === "string" ||
|
|
16
16
|
typeof date === "number"));
|
|
17
17
|
}
|
|
@@ -55,6 +55,18 @@ export const defineTableChartFormat = (column, settings) => {
|
|
|
55
55
|
return selectedFormat;
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
+
case COLUMN.TIME: {
|
|
59
|
+
if (noFormatSupported)
|
|
60
|
+
return STRING_FORMAT.NONE;
|
|
61
|
+
if (selectedFormat)
|
|
62
|
+
return selectedFormat;
|
|
63
|
+
if (hasDefaultFormat) {
|
|
64
|
+
const columnDefaultFormat = defaultFormat ||
|
|
65
|
+
outputFormat || { type: "TIME", format: "HH:mm:ss" };
|
|
66
|
+
return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, columnDefaultFormat), type: "TIME" });
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
58
70
|
case COLUMN.NUMERIC:
|
|
59
71
|
case COLUMN.RATING:
|
|
60
72
|
case COLUMN.SLIDEBAR: {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { DATE_FORMAT } from "../constants";
|
|
2
|
+
import { isValidPotentialDate } from "./isValidPotentialDate";
|
|
3
|
+
import { validateDate } from "./validateDate";
|
|
1
4
|
/**
|
|
2
5
|
* Adjusts a Date with the UTC-0 Timezone.
|
|
3
6
|
* @param date String, object or millisencond number of the date
|
|
4
7
|
* @returns updated Date object
|
|
5
8
|
*/
|
|
6
9
|
export function adjustTimezone(date) {
|
|
10
|
+
if (!isValidPotentialDate(date) ||
|
|
11
|
+
(typeof date === "string" && !validateDate(date, DATE_FORMAT.DAY)))
|
|
12
|
+
return date;
|
|
7
13
|
const dt = new Date(date.valueOf());
|
|
8
14
|
return new Date(+dt + dt.getTimezoneOffset() * 1000 * 60);
|
|
9
15
|
}
|
|
@@ -8,7 +8,7 @@ import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
|
8
8
|
export function isValidPotentialDate(date) {
|
|
9
9
|
return (!isEmpty(date) &&
|
|
10
10
|
!isTokenLabel(date) &&
|
|
11
|
-
(date instanceof Date ||
|
|
11
|
+
((date instanceof Date && !isNaN(date)) ||
|
|
12
12
|
typeof date === "string" ||
|
|
13
13
|
typeof date === "number"));
|
|
14
14
|
}
|