@qrvey/utils 1.10.0-2 → 1.10.0-3
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/dates/adapters/numericOffsetToISO.d.ts +1 -1
- package/dist/cjs/dates/adapters/numericOffsetToISO.js +12 -7
- package/dist/cjs/dates/helpers/getTimezoneObject.js +44 -3
- package/dist/cjs/dates/helpers/getUTCFormatByOffset.d.ts +7 -0
- package/dist/cjs/dates/helpers/getUTCFormatByOffset.js +19 -0
- package/dist/cjs/dates/helpers/index.d.ts +1 -0
- package/dist/cjs/dates/helpers/index.js +1 -0
- package/dist/cjs/filters/services/Filters.api.js +1 -1
- package/dist/cjs/format/localization.js +10 -1
- package/dist/cjs/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +3 -3
- package/dist/cjs/interfaces/format/IFormatConfig.Interface.d.ts +1 -1
- package/dist/dates/adapters/numericOffsetToISO.d.ts +1 -1
- package/dist/dates/adapters/numericOffsetToISO.js +12 -7
- package/dist/dates/helpers/getTimezoneObject.js +44 -3
- package/dist/dates/helpers/getUTCFormatByOffset.d.ts +7 -0
- package/dist/dates/helpers/getUTCFormatByOffset.js +15 -0
- package/dist/dates/helpers/index.d.ts +1 -0
- package/dist/dates/helpers/index.js +1 -0
- package/dist/filters/services/Filters.api.js +1 -1
- package/dist/format/localization.js +10 -1
- package/dist/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +3 -3
- package/dist/interfaces/format/IFormatConfig.Interface.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @param {number} offset the timezone offset
|
|
4
4
|
* @returns {string} the offset in minutes
|
|
5
5
|
*/
|
|
6
|
-
export declare function numericOffsetToISO(offset: number | string): string;
|
|
6
|
+
export declare function numericOffsetToISO(offset: number | string, leadZeros?: boolean): string;
|
|
@@ -5,25 +5,30 @@ const isNaNV2_1 = require("../../general/mix/isNaNV2");
|
|
|
5
5
|
const getSign_1 = require("../../general/numeric/getSign");
|
|
6
6
|
const padLeadingZeros_1 = require("../../general/string/padLeadingZeros");
|
|
7
7
|
const isValidISOOffset_1 = require("../helpers/isValidISOOffset");
|
|
8
|
+
const ISOToNumericOffset_1 = require("./ISOToNumericOffset");
|
|
8
9
|
/**
|
|
9
10
|
* Gets the ISO offset From the numeric offset (minutes)
|
|
10
11
|
* @param {number} offset the timezone offset
|
|
11
12
|
* @returns {string} the offset in minutes
|
|
12
13
|
*/
|
|
13
|
-
function numericOffsetToISO(offset) {
|
|
14
|
+
function numericOffsetToISO(offset, leadZeros = true) {
|
|
15
|
+
const leadZeroNumber = leadZeros ? 2 : 0;
|
|
14
16
|
let newOffset = offset;
|
|
15
|
-
if (typeof
|
|
17
|
+
if (typeof newOffset === "string" && newOffset === "browser")
|
|
16
18
|
newOffset = -1 * new Date().getTimezoneOffset();
|
|
17
|
-
if (typeof newOffset === "string" && (0, isValidISOOffset_1.isValidISOOffset)(newOffset))
|
|
18
|
-
|
|
19
|
+
if (typeof newOffset === "string" && (0, isValidISOOffset_1.isValidISOOffset)(newOffset)) {
|
|
20
|
+
if (leadZeros)
|
|
21
|
+
return String(newOffset);
|
|
22
|
+
newOffset = (0, ISOToNumericOffset_1.ISOToNumericOffset)(newOffset);
|
|
23
|
+
}
|
|
19
24
|
if (typeof newOffset !== "number" && (0, isNaNV2_1.isNaNV2)(newOffset))
|
|
20
|
-
return "+00:00";
|
|
25
|
+
return leadZeros ? "+00:00" : "+0:0";
|
|
21
26
|
if (typeof newOffset === "string" && !(0, isNaNV2_1.isNaNV2)(newOffset))
|
|
22
27
|
newOffset = +newOffset;
|
|
23
28
|
const sign = (0, getSign_1.getSign)(newOffset);
|
|
24
29
|
newOffset = Math.abs(newOffset);
|
|
25
|
-
const hours = (0, padLeadingZeros_1.padLeadingZeros)(Math.floor(newOffset / 60),
|
|
26
|
-
const minutes = (0, padLeadingZeros_1.padLeadingZeros)(newOffset % 60,
|
|
30
|
+
const hours = (0, padLeadingZeros_1.padLeadingZeros)(Math.floor(newOffset / 60), leadZeroNumber);
|
|
31
|
+
const minutes = (0, padLeadingZeros_1.padLeadingZeros)(newOffset % 60, leadZeroNumber);
|
|
27
32
|
return `${sign}${hours}:${minutes}`;
|
|
28
33
|
}
|
|
29
34
|
exports.numericOffsetToISO = numericOffsetToISO;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTimezoneObject = void 0;
|
|
4
|
+
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
4
5
|
const TIMEZONE_TYPE_1 = require("../constants/TIMEZONE_TYPE");
|
|
5
6
|
const getTimezoneOffsetByType_1 = require("./getTimezoneOffsetByType");
|
|
7
|
+
const isValidISOOffset_1 = require("./isValidISOOffset");
|
|
6
8
|
/**
|
|
7
9
|
* Gets the timezone object by the given argument or the model object
|
|
8
10
|
* @param {IDTimezone} timezone the timezone object
|
|
@@ -10,12 +12,51 @@ const getTimezoneOffsetByType_1 = require("./getTimezoneOffsetByType");
|
|
|
10
12
|
* @returns a new timezone object
|
|
11
13
|
*/
|
|
12
14
|
function getTimezoneObject(timezone, model) {
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const type = (timezone === null || timezone === void 0 ? void 0 : timezone.type) || ((_b = model === null || model === void 0 ? void 0 : model.timezone) === null || _b === void 0 ? void 0 : _b.type) || TIMEZONE_TYPE_1.TIMEZONE_TYPE.DEFAULT;
|
|
15
|
+
const offset = getOffset(timezone, model);
|
|
16
|
+
const type = getType(timezone, model, offset);
|
|
16
17
|
return {
|
|
17
18
|
offset: (0, getTimezoneOffsetByType_1.getTimezoneOffsetByType)({ offset, type }),
|
|
18
19
|
type,
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
exports.getTimezoneObject = getTimezoneObject;
|
|
23
|
+
function getOffset(timezone, model) {
|
|
24
|
+
var _a;
|
|
25
|
+
let offset;
|
|
26
|
+
if (!(0, isEmpty_1.isEmpty)(timezone === null || timezone === void 0 ? void 0 : timezone.offset)) {
|
|
27
|
+
offset = timezone.offset;
|
|
28
|
+
}
|
|
29
|
+
else if (!(0, isEmpty_1.isEmpty)((_a = model === null || model === void 0 ? void 0 : model.timezone) === null || _a === void 0 ? void 0 : _a.offset)) {
|
|
30
|
+
offset = model.timezone.offset;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
offset = "+00:00";
|
|
34
|
+
}
|
|
35
|
+
return offset;
|
|
36
|
+
}
|
|
37
|
+
function getType(timezone, model, offset) {
|
|
38
|
+
var _a;
|
|
39
|
+
let type;
|
|
40
|
+
if (!(0, isEmpty_1.isEmpty)(timezone === null || timezone === void 0 ? void 0 : timezone.type)) {
|
|
41
|
+
type = timezone.type;
|
|
42
|
+
}
|
|
43
|
+
else if (!(0, isEmpty_1.isEmpty)((_a = model === null || model === void 0 ? void 0 : model.timezone) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
44
|
+
type = model.timezone.type;
|
|
45
|
+
}
|
|
46
|
+
if ((0, isEmpty_1.isEmpty)(type)) {
|
|
47
|
+
type = getTypeByOffset(offset);
|
|
48
|
+
}
|
|
49
|
+
return type;
|
|
50
|
+
}
|
|
51
|
+
function getTypeByOffset(offset) {
|
|
52
|
+
if (offset === "+00:00") {
|
|
53
|
+
return TIMEZONE_TYPE_1.TIMEZONE_TYPE.DEFAULT;
|
|
54
|
+
}
|
|
55
|
+
else if (offset === "browser") {
|
|
56
|
+
return TIMEZONE_TYPE_1.TIMEZONE_TYPE.BROWSER;
|
|
57
|
+
}
|
|
58
|
+
else if ((0, isValidISOOffset_1.isValidISOOffset)(offset)) {
|
|
59
|
+
return TIMEZONE_TYPE_1.TIMEZONE_TYPE.FIXED;
|
|
60
|
+
}
|
|
61
|
+
return TIMEZONE_TYPE_1.TIMEZONE_TYPE.DEFAULT;
|
|
62
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the UTC format dependeing on the given offset
|
|
4
|
+
* @param {IDTimezone} timezone the timezone object
|
|
5
|
+
* @returns {string} an string with the UTC format
|
|
6
|
+
*/
|
|
7
|
+
export declare function getUTCFormatByOffset(timezone: IDTimezone): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUTCFormatByOffset = void 0;
|
|
4
|
+
const numericOffsetToISO_1 = require("../adapters/numericOffsetToISO");
|
|
5
|
+
const getTimezoneObject_1 = require("./getTimezoneObject");
|
|
6
|
+
/**
|
|
7
|
+
* Gets the UTC format dependeing on the given offset
|
|
8
|
+
* @param {IDTimezone} timezone the timezone object
|
|
9
|
+
* @returns {string} an string with the UTC format
|
|
10
|
+
*/
|
|
11
|
+
function getUTCFormatByOffset(timezone) {
|
|
12
|
+
const newTimezone = (0, getTimezoneObject_1.getTimezoneObject)(timezone, undefined);
|
|
13
|
+
let newOffset = (0, numericOffsetToISO_1.numericOffsetToISO)(newTimezone === null || newTimezone === void 0 ? void 0 : newTimezone.offset, false);
|
|
14
|
+
if (newOffset.search(":0") > -1) {
|
|
15
|
+
newOffset = newOffset.slice(0, newOffset.indexOf(":"));
|
|
16
|
+
}
|
|
17
|
+
return `UTC${newOffset}`;
|
|
18
|
+
}
|
|
19
|
+
exports.getUTCFormatByOffset = getUTCFormatByOffset;
|
|
@@ -10,6 +10,7 @@ export * from "./getFormattedDateByFormat";
|
|
|
10
10
|
export * from "./getSeparatorByDateFormat";
|
|
11
11
|
export * from "./getTimezoneObject";
|
|
12
12
|
export * from "./getTimezoneOffsetByType";
|
|
13
|
+
export * from "./getUTCFormatByOffset";
|
|
13
14
|
export * from "./getWeek";
|
|
14
15
|
export * from "./isValidDateObject";
|
|
15
16
|
export * from "./isValidPotentialDate";
|
|
@@ -26,6 +26,7 @@ __exportStar(require("./getFormattedDateByFormat"), exports);
|
|
|
26
26
|
__exportStar(require("./getSeparatorByDateFormat"), exports);
|
|
27
27
|
__exportStar(require("./getTimezoneObject"), exports);
|
|
28
28
|
__exportStar(require("./getTimezoneOffsetByType"), exports);
|
|
29
|
+
__exportStar(require("./getUTCFormatByOffset"), exports);
|
|
29
30
|
__exportStar(require("./getWeek"), exports);
|
|
30
31
|
__exportStar(require("./isValidDateObject"), exports);
|
|
31
32
|
__exportStar(require("./isValidPotentialDate"), exports);
|
|
@@ -103,7 +103,7 @@ class FiltersApi {
|
|
|
103
103
|
else {
|
|
104
104
|
api = this.chartPaginationApi;
|
|
105
105
|
}
|
|
106
|
-
return api.getChartResult(this.config, FiltersApi.getFilter(config), FiltersApi.getLogic(config), FiltersApi.getChartRequest(config), resetApi);
|
|
106
|
+
return api.getChartResult(Object.assign(Object.assign({}, this.config), { timezone: config.widgetConfig.timezone }), FiltersApi.getFilter(config), FiltersApi.getLogic(config), FiltersApi.getChartRequest(config), resetApi);
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
static getLogic(config) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatWithLocale = exports.chooseLang = exports.getLang = void 0;
|
|
4
|
+
const dates_1 = require("../dates");
|
|
4
5
|
const isEmpty_1 = require("../general/mix/isEmpty");
|
|
5
6
|
const definition_1 = require("./definition");
|
|
6
7
|
const durationFormatter_1 = require("./duration/durationFormatter");
|
|
@@ -29,11 +30,19 @@ const formatWithLocale = (value, outputFormat, config = {}) => {
|
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
exports.formatWithLocale = formatWithLocale;
|
|
33
|
+
function getDateWithOffset(dateValue, offset) {
|
|
34
|
+
const targetTime = new Date(dateValue);
|
|
35
|
+
if (!(0, isEmpty_1.isEmpty)(offset))
|
|
36
|
+
targetTime.setUTCMinutes(targetTime.getUTCMinutes() +
|
|
37
|
+
targetTime.getTimezoneOffset() +
|
|
38
|
+
(0, dates_1.ISOToNumericOffset)(offset));
|
|
39
|
+
return targetTime;
|
|
40
|
+
}
|
|
32
41
|
const DATE_FORMAT_CACHE = [];
|
|
33
42
|
function formatLocaleDate(value, outputFormat, config) {
|
|
34
43
|
const { lang = definition_1.LANG_DEFAULT, options } = config;
|
|
35
44
|
const dateValue = value === null || value === void 0 ? void 0 : value.replace(/Z$/i, "");
|
|
36
|
-
const dateParam =
|
|
45
|
+
const dateParam = getDateWithOffset(dateValue, config === null || config === void 0 ? void 0 : config.offset);
|
|
37
46
|
let langOpts = options;
|
|
38
47
|
if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
|
|
39
48
|
if ((0, isDateTimeFormat_1.isDateTimeFormat)(outputFormat))
|
|
@@ -362,7 +362,7 @@ exports.I18N_FORMULA_BUILDER = {
|
|
|
362
362
|
},
|
|
363
363
|
function_date_add: {
|
|
364
364
|
description: "Given a Date or a Column, add the specific value to the specific part.",
|
|
365
|
-
function_placeholder: "dateAdd(date, date_part, interval_value)",
|
|
365
|
+
function_placeholder: "dateAdd(date, 'date_part', interval_value)",
|
|
366
366
|
param_date_name: "date",
|
|
367
367
|
param_date_description: "This is the Date or Column to which you want to add.",
|
|
368
368
|
param_part_name: "date_part",
|
|
@@ -372,7 +372,7 @@ exports.I18N_FORMULA_BUILDER = {
|
|
|
372
372
|
},
|
|
373
373
|
function_date_subtract: {
|
|
374
374
|
description: "Given a Date or a Column, subtract the specific value to the specific part.",
|
|
375
|
-
function_placeholder: "dateSubtract(date, date_part, interval_value)",
|
|
375
|
+
function_placeholder: "dateSubtract(date, 'date_part', interval_value)",
|
|
376
376
|
param_date_name: "date",
|
|
377
377
|
param_date_description: "This is the Date or Column to which you want to subtract.",
|
|
378
378
|
param_part_name: "date_part",
|
|
@@ -382,7 +382,7 @@ exports.I18N_FORMULA_BUILDER = {
|
|
|
382
382
|
},
|
|
383
383
|
function_date_diff: {
|
|
384
384
|
description: "Calculates the difference between two dates based on the date part requested.",
|
|
385
|
-
function_placeholder: "dateDiff(date_value1, date_value2, date_part)",
|
|
385
|
+
function_placeholder: "dateDiff(date_value1, date_value2, 'date_part')",
|
|
386
386
|
param_date_value_one_name: "date_value1",
|
|
387
387
|
param_date_value_one_description: "The first date value.",
|
|
388
388
|
param_date_value_two_name: "date_value2",
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @param {number} offset the timezone offset
|
|
4
4
|
* @returns {string} the offset in minutes
|
|
5
5
|
*/
|
|
6
|
-
export declare function numericOffsetToISO(offset: number | string): string;
|
|
6
|
+
export declare function numericOffsetToISO(offset: number | string, leadZeros?: boolean): string;
|
|
@@ -2,24 +2,29 @@ import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
|
2
2
|
import { getSign } from "../../general/numeric/getSign";
|
|
3
3
|
import { padLeadingZeros } from "../../general/string/padLeadingZeros";
|
|
4
4
|
import { isValidISOOffset } from "../helpers/isValidISOOffset";
|
|
5
|
+
import { ISOToNumericOffset } from "./ISOToNumericOffset";
|
|
5
6
|
/**
|
|
6
7
|
* Gets the ISO offset From the numeric offset (minutes)
|
|
7
8
|
* @param {number} offset the timezone offset
|
|
8
9
|
* @returns {string} the offset in minutes
|
|
9
10
|
*/
|
|
10
|
-
export function numericOffsetToISO(offset) {
|
|
11
|
+
export function numericOffsetToISO(offset, leadZeros = true) {
|
|
12
|
+
const leadZeroNumber = leadZeros ? 2 : 0;
|
|
11
13
|
let newOffset = offset;
|
|
12
|
-
if (typeof
|
|
14
|
+
if (typeof newOffset === "string" && newOffset === "browser")
|
|
13
15
|
newOffset = -1 * new Date().getTimezoneOffset();
|
|
14
|
-
if (typeof newOffset === "string" && isValidISOOffset(newOffset))
|
|
15
|
-
|
|
16
|
+
if (typeof newOffset === "string" && isValidISOOffset(newOffset)) {
|
|
17
|
+
if (leadZeros)
|
|
18
|
+
return String(newOffset);
|
|
19
|
+
newOffset = ISOToNumericOffset(newOffset);
|
|
20
|
+
}
|
|
16
21
|
if (typeof newOffset !== "number" && isNaNV2(newOffset))
|
|
17
|
-
return "+00:00";
|
|
22
|
+
return leadZeros ? "+00:00" : "+0:0";
|
|
18
23
|
if (typeof newOffset === "string" && !isNaNV2(newOffset))
|
|
19
24
|
newOffset = +newOffset;
|
|
20
25
|
const sign = getSign(newOffset);
|
|
21
26
|
newOffset = Math.abs(newOffset);
|
|
22
|
-
const hours = padLeadingZeros(Math.floor(newOffset / 60),
|
|
23
|
-
const minutes = padLeadingZeros(newOffset % 60,
|
|
27
|
+
const hours = padLeadingZeros(Math.floor(newOffset / 60), leadZeroNumber);
|
|
28
|
+
const minutes = padLeadingZeros(newOffset % 60, leadZeroNumber);
|
|
24
29
|
return `${sign}${hours}:${minutes}`;
|
|
25
30
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
1
2
|
import { TIMEZONE_TYPE } from "../constants/TIMEZONE_TYPE";
|
|
2
3
|
import { getTimezoneOffsetByType } from "./getTimezoneOffsetByType";
|
|
4
|
+
import { isValidISOOffset } from "./isValidISOOffset";
|
|
3
5
|
/**
|
|
4
6
|
* Gets the timezone object by the given argument or the model object
|
|
5
7
|
* @param {IDTimezone} timezone the timezone object
|
|
@@ -7,11 +9,50 @@ import { getTimezoneOffsetByType } from "./getTimezoneOffsetByType";
|
|
|
7
9
|
* @returns a new timezone object
|
|
8
10
|
*/
|
|
9
11
|
export function getTimezoneObject(timezone, model) {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const type = (timezone === null || timezone === void 0 ? void 0 : timezone.type) || ((_b = model === null || model === void 0 ? void 0 : model.timezone) === null || _b === void 0 ? void 0 : _b.type) || TIMEZONE_TYPE.DEFAULT;
|
|
12
|
+
const offset = getOffset(timezone, model);
|
|
13
|
+
const type = getType(timezone, model, offset);
|
|
13
14
|
return {
|
|
14
15
|
offset: getTimezoneOffsetByType({ offset, type }),
|
|
15
16
|
type,
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
function getOffset(timezone, model) {
|
|
20
|
+
var _a;
|
|
21
|
+
let offset;
|
|
22
|
+
if (!isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.offset)) {
|
|
23
|
+
offset = timezone.offset;
|
|
24
|
+
}
|
|
25
|
+
else if (!isEmpty((_a = model === null || model === void 0 ? void 0 : model.timezone) === null || _a === void 0 ? void 0 : _a.offset)) {
|
|
26
|
+
offset = model.timezone.offset;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
offset = "+00:00";
|
|
30
|
+
}
|
|
31
|
+
return offset;
|
|
32
|
+
}
|
|
33
|
+
function getType(timezone, model, offset) {
|
|
34
|
+
var _a;
|
|
35
|
+
let type;
|
|
36
|
+
if (!isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.type)) {
|
|
37
|
+
type = timezone.type;
|
|
38
|
+
}
|
|
39
|
+
else if (!isEmpty((_a = model === null || model === void 0 ? void 0 : model.timezone) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
40
|
+
type = model.timezone.type;
|
|
41
|
+
}
|
|
42
|
+
if (isEmpty(type)) {
|
|
43
|
+
type = getTypeByOffset(offset);
|
|
44
|
+
}
|
|
45
|
+
return type;
|
|
46
|
+
}
|
|
47
|
+
function getTypeByOffset(offset) {
|
|
48
|
+
if (offset === "+00:00") {
|
|
49
|
+
return TIMEZONE_TYPE.DEFAULT;
|
|
50
|
+
}
|
|
51
|
+
else if (offset === "browser") {
|
|
52
|
+
return TIMEZONE_TYPE.BROWSER;
|
|
53
|
+
}
|
|
54
|
+
else if (isValidISOOffset(offset)) {
|
|
55
|
+
return TIMEZONE_TYPE.FIXED;
|
|
56
|
+
}
|
|
57
|
+
return TIMEZONE_TYPE.DEFAULT;
|
|
58
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the UTC format dependeing on the given offset
|
|
4
|
+
* @param {IDTimezone} timezone the timezone object
|
|
5
|
+
* @returns {string} an string with the UTC format
|
|
6
|
+
*/
|
|
7
|
+
export declare function getUTCFormatByOffset(timezone: IDTimezone): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { numericOffsetToISO } from "../adapters/numericOffsetToISO";
|
|
2
|
+
import { getTimezoneObject } from "./getTimezoneObject";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the UTC format dependeing on the given offset
|
|
5
|
+
* @param {IDTimezone} timezone the timezone object
|
|
6
|
+
* @returns {string} an string with the UTC format
|
|
7
|
+
*/
|
|
8
|
+
export function getUTCFormatByOffset(timezone) {
|
|
9
|
+
const newTimezone = getTimezoneObject(timezone, undefined);
|
|
10
|
+
let newOffset = numericOffsetToISO(newTimezone === null || newTimezone === void 0 ? void 0 : newTimezone.offset, false);
|
|
11
|
+
if (newOffset.search(":0") > -1) {
|
|
12
|
+
newOffset = newOffset.slice(0, newOffset.indexOf(":"));
|
|
13
|
+
}
|
|
14
|
+
return `UTC${newOffset}`;
|
|
15
|
+
}
|
|
@@ -10,6 +10,7 @@ export * from "./getFormattedDateByFormat";
|
|
|
10
10
|
export * from "./getSeparatorByDateFormat";
|
|
11
11
|
export * from "./getTimezoneObject";
|
|
12
12
|
export * from "./getTimezoneOffsetByType";
|
|
13
|
+
export * from "./getUTCFormatByOffset";
|
|
13
14
|
export * from "./getWeek";
|
|
14
15
|
export * from "./isValidDateObject";
|
|
15
16
|
export * from "./isValidPotentialDate";
|
|
@@ -10,6 +10,7 @@ export * from "./getFormattedDateByFormat";
|
|
|
10
10
|
export * from "./getSeparatorByDateFormat";
|
|
11
11
|
export * from "./getTimezoneObject";
|
|
12
12
|
export * from "./getTimezoneOffsetByType";
|
|
13
|
+
export * from "./getUTCFormatByOffset";
|
|
13
14
|
export * from "./getWeek";
|
|
14
15
|
export * from "./isValidDateObject";
|
|
15
16
|
export * from "./isValidPotentialDate";
|
|
@@ -97,7 +97,7 @@ export class FiltersApi {
|
|
|
97
97
|
else {
|
|
98
98
|
api = this.chartPaginationApi;
|
|
99
99
|
}
|
|
100
|
-
return api.getChartResult(this.config, FiltersApi.getFilter(config), FiltersApi.getLogic(config), FiltersApi.getChartRequest(config), resetApi);
|
|
100
|
+
return api.getChartResult(Object.assign(Object.assign({}, this.config), { timezone: config.widgetConfig.timezone }), FiltersApi.getFilter(config), FiltersApi.getLogic(config), FiltersApi.getChartRequest(config), resetApi);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
static getLogic(config) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ISOToNumericOffset } from "../dates";
|
|
1
2
|
import { isEmpty } from "../general/mix/isEmpty";
|
|
2
3
|
import { currencyISO, LANG_DEFAULT, CURRENCY_DEFAULT, DATETIME_OPTIONS, } from "./definition";
|
|
3
4
|
import { DurationFormatter } from "./duration/durationFormatter";
|
|
@@ -23,11 +24,19 @@ export const formatWithLocale = (value, outputFormat, config = {}) => {
|
|
|
23
24
|
return formatLocaleNumber(value, outputFormat, config);
|
|
24
25
|
}
|
|
25
26
|
};
|
|
27
|
+
function getDateWithOffset(dateValue, offset) {
|
|
28
|
+
const targetTime = new Date(dateValue);
|
|
29
|
+
if (!isEmpty(offset))
|
|
30
|
+
targetTime.setUTCMinutes(targetTime.getUTCMinutes() +
|
|
31
|
+
targetTime.getTimezoneOffset() +
|
|
32
|
+
ISOToNumericOffset(offset));
|
|
33
|
+
return targetTime;
|
|
34
|
+
}
|
|
26
35
|
const DATE_FORMAT_CACHE = [];
|
|
27
36
|
function formatLocaleDate(value, outputFormat, config) {
|
|
28
37
|
const { lang = LANG_DEFAULT, options } = config;
|
|
29
38
|
const dateValue = value === null || value === void 0 ? void 0 : value.replace(/Z$/i, "");
|
|
30
|
-
const dateParam =
|
|
39
|
+
const dateParam = getDateWithOffset(dateValue, config === null || config === void 0 ? void 0 : config.offset);
|
|
31
40
|
let langOpts = options;
|
|
32
41
|
if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
|
|
33
42
|
if (isDateTimeFormat(outputFormat))
|
|
@@ -359,7 +359,7 @@ export const I18N_FORMULA_BUILDER = {
|
|
|
359
359
|
},
|
|
360
360
|
function_date_add: {
|
|
361
361
|
description: "Given a Date or a Column, add the specific value to the specific part.",
|
|
362
|
-
function_placeholder: "dateAdd(date, date_part, interval_value)",
|
|
362
|
+
function_placeholder: "dateAdd(date, 'date_part', interval_value)",
|
|
363
363
|
param_date_name: "date",
|
|
364
364
|
param_date_description: "This is the Date or Column to which you want to add.",
|
|
365
365
|
param_part_name: "date_part",
|
|
@@ -369,7 +369,7 @@ export const I18N_FORMULA_BUILDER = {
|
|
|
369
369
|
},
|
|
370
370
|
function_date_subtract: {
|
|
371
371
|
description: "Given a Date or a Column, subtract the specific value to the specific part.",
|
|
372
|
-
function_placeholder: "dateSubtract(date, date_part, interval_value)",
|
|
372
|
+
function_placeholder: "dateSubtract(date, 'date_part', interval_value)",
|
|
373
373
|
param_date_name: "date",
|
|
374
374
|
param_date_description: "This is the Date or Column to which you want to subtract.",
|
|
375
375
|
param_part_name: "date_part",
|
|
@@ -379,7 +379,7 @@ export const I18N_FORMULA_BUILDER = {
|
|
|
379
379
|
},
|
|
380
380
|
function_date_diff: {
|
|
381
381
|
description: "Calculates the difference between two dates based on the date part requested.",
|
|
382
|
-
function_placeholder: "dateDiff(date_value1, date_value2, date_part)",
|
|
382
|
+
function_placeholder: "dateDiff(date_value1, date_value2, 'date_part')",
|
|
383
383
|
param_date_value_one_name: "date_value1",
|
|
384
384
|
param_date_value_one_description: "The first date value.",
|
|
385
385
|
param_date_value_two_name: "date_value2",
|