@qrvey/utils 1.10.0-3 → 1.10.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/dates/helpers/getTimezoneObject.d.ts +2 -1
- package/dist/cjs/dates/helpers/getTimezoneObject.js +46 -1
- package/dist/cjs/dates/helpers/getUTCFormatByOffset.js +1 -3
- package/dist/cjs/dates/interfaces/IDTimezone.d.ts +1 -0
- package/dist/cjs/globalization/labels/filters/I18N_RELATIVE_CONTAINER.js +1 -1
- package/dist/dates/helpers/getTimezoneObject.d.ts +2 -1
- package/dist/dates/helpers/getTimezoneObject.js +46 -1
- package/dist/dates/helpers/getUTCFormatByOffset.js +1 -3
- package/dist/dates/interfaces/IDTimezone.d.ts +1 -0
- package/dist/globalization/labels/filters/I18N_RELATIVE_CONTAINER.js +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,9 @@ import { IModel } from "../../qrvey/interfaces/IModel";
|
|
|
3
3
|
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
4
4
|
/**
|
|
5
5
|
* Gets the timezone object by the given argument or the model object
|
|
6
|
+
* - In any case, the offset is prioritized to override other properties.
|
|
6
7
|
* @param {IDTimezone} timezone the timezone object
|
|
7
8
|
* @param {IModel | IDataset} model the info of the dataset (model)
|
|
8
9
|
* @returns a new timezone object
|
|
9
10
|
*/
|
|
10
|
-
export declare function getTimezoneObject(timezone: IDTimezone, model
|
|
11
|
+
export declare function getTimezoneObject(timezone: IDTimezone, model?: IModel | IDataset): IDTimezone;
|
|
@@ -4,9 +4,11 @@ exports.getTimezoneObject = void 0;
|
|
|
4
4
|
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
5
5
|
const TIMEZONE_TYPE_1 = require("../constants/TIMEZONE_TYPE");
|
|
6
6
|
const getTimezoneOffsetByType_1 = require("./getTimezoneOffsetByType");
|
|
7
|
+
const getUTCFormatByOffset_1 = require("./getUTCFormatByOffset");
|
|
7
8
|
const isValidISOOffset_1 = require("./isValidISOOffset");
|
|
8
9
|
/**
|
|
9
10
|
* Gets the timezone object by the given argument or the model object
|
|
11
|
+
* - In any case, the offset is prioritized to override other properties.
|
|
10
12
|
* @param {IDTimezone} timezone the timezone object
|
|
11
13
|
* @param {IModel | IDataset} model the info of the dataset (model)
|
|
12
14
|
* @returns a new timezone object
|
|
@@ -14,12 +16,24 @@ const isValidISOOffset_1 = require("./isValidISOOffset");
|
|
|
14
16
|
function getTimezoneObject(timezone, model) {
|
|
15
17
|
const offset = getOffset(timezone, model);
|
|
16
18
|
const type = getType(timezone, model, offset);
|
|
19
|
+
const resultingOffset = (0, getTimezoneOffsetByType_1.getTimezoneOffsetByType)({ offset, type });
|
|
20
|
+
const utc = getUTC({ offset: resultingOffset, type });
|
|
17
21
|
return {
|
|
18
|
-
offset:
|
|
22
|
+
offset: resultingOffset,
|
|
19
23
|
type,
|
|
24
|
+
utc,
|
|
20
25
|
};
|
|
21
26
|
}
|
|
22
27
|
exports.getTimezoneObject = getTimezoneObject;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the offset of the timezone by the given objects
|
|
30
|
+
* - Searchs the first argument
|
|
31
|
+
* - If the timezone is empty, in the model timezone is searched
|
|
32
|
+
* - If it does not exist in any, a default one is set.
|
|
33
|
+
* @param {IDTimezone} timezone The timezone object
|
|
34
|
+
* @param {IModel | IDataset} model The model info
|
|
35
|
+
* @returns {IDTimezoneOffset} the offset of the objects
|
|
36
|
+
*/
|
|
23
37
|
function getOffset(timezone, model) {
|
|
24
38
|
var _a;
|
|
25
39
|
let offset;
|
|
@@ -34,12 +48,26 @@ function getOffset(timezone, model) {
|
|
|
34
48
|
}
|
|
35
49
|
return offset;
|
|
36
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Gets the type of the timezone
|
|
53
|
+
* - Searchs the first argument
|
|
54
|
+
* - If it does not exist, asking for the timezone offset in order to prioritized the offset above all.
|
|
55
|
+
* - If the timezone is empty, in the model timezone is searched.
|
|
56
|
+
* - If it does not exist in any, a default one is set.
|
|
57
|
+
* @param {IDTimezone} timezone The timezone object
|
|
58
|
+
* @param {IModel | IDataset} model The model info
|
|
59
|
+
* @param {IDTimezoneOffset} offset a default offset if the validation are not satisfied
|
|
60
|
+
* @returns {IDTimezoneType} the rigth type of the timezone
|
|
61
|
+
*/
|
|
37
62
|
function getType(timezone, model, offset) {
|
|
38
63
|
var _a;
|
|
39
64
|
let type;
|
|
40
65
|
if (!(0, isEmpty_1.isEmpty)(timezone === null || timezone === void 0 ? void 0 : timezone.type)) {
|
|
41
66
|
type = timezone.type;
|
|
42
67
|
}
|
|
68
|
+
else if (!(0, isEmpty_1.isEmpty)(timezone === null || timezone === void 0 ? void 0 : timezone.offset)) {
|
|
69
|
+
type = getTypeByOffset(timezone === null || timezone === void 0 ? void 0 : timezone.offset);
|
|
70
|
+
}
|
|
43
71
|
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
72
|
type = model.timezone.type;
|
|
45
73
|
}
|
|
@@ -48,6 +76,15 @@ function getType(timezone, model, offset) {
|
|
|
48
76
|
}
|
|
49
77
|
return type;
|
|
50
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets the type by a offset
|
|
81
|
+
* - For a offset=0 the type is default
|
|
82
|
+
* - For a offset="browser" the type is browser
|
|
83
|
+
* - For a valid offset different to previous ones, the type is fixed;
|
|
84
|
+
* - Anything else, it is considered default.
|
|
85
|
+
* @param {IDTimezoneOffset} offset a given offset
|
|
86
|
+
* @returns {IDTimezoneType} the right timezone type for the offset
|
|
87
|
+
*/
|
|
51
88
|
function getTypeByOffset(offset) {
|
|
52
89
|
if (offset === "+00:00") {
|
|
53
90
|
return TIMEZONE_TYPE_1.TIMEZONE_TYPE.DEFAULT;
|
|
@@ -60,3 +97,11 @@ function getTypeByOffset(offset) {
|
|
|
60
97
|
}
|
|
61
98
|
return TIMEZONE_TYPE_1.TIMEZONE_TYPE.DEFAULT;
|
|
62
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Gets the UTC string by the timezone object
|
|
102
|
+
* @param {IDTimezone} timezone the timezone object
|
|
103
|
+
* @returns {string} the label of the UTC value
|
|
104
|
+
*/
|
|
105
|
+
function getUTC(timezone) {
|
|
106
|
+
return (0, getUTCFormatByOffset_1.getUTCFormatByOffset)(timezone);
|
|
107
|
+
}
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUTCFormatByOffset = void 0;
|
|
4
4
|
const numericOffsetToISO_1 = require("../adapters/numericOffsetToISO");
|
|
5
|
-
const getTimezoneObject_1 = require("./getTimezoneObject");
|
|
6
5
|
/**
|
|
7
6
|
* Gets the UTC format dependeing on the given offset
|
|
8
7
|
* @param {IDTimezone} timezone the timezone object
|
|
9
8
|
* @returns {string} an string with the UTC format
|
|
10
9
|
*/
|
|
11
10
|
function getUTCFormatByOffset(timezone) {
|
|
12
|
-
|
|
13
|
-
let newOffset = (0, numericOffsetToISO_1.numericOffsetToISO)(newTimezone === null || newTimezone === void 0 ? void 0 : newTimezone.offset, false);
|
|
11
|
+
let newOffset = (0, numericOffsetToISO_1.numericOffsetToISO)(timezone === null || timezone === void 0 ? void 0 : timezone.offset, false);
|
|
14
12
|
if (newOffset.search(":0") > -1) {
|
|
15
13
|
newOffset = newOffset.slice(0, newOffset.indexOf(":"));
|
|
16
14
|
}
|
|
@@ -13,5 +13,5 @@ exports.I18N_RELATIVE_CONTAINER = {
|
|
|
13
13
|
starting_date_tooltip: "The relative date will include the specific starting date and a period of time to show from that date onwards (Inclusive range). <br/> Unchecking this option will exclude the chosen starting date (exclusive range) from the date range.",
|
|
14
14
|
starting_from: "Starting From",
|
|
15
15
|
set_current_date: "Set to current date",
|
|
16
|
-
utc_tooltip: "The times displayed are in
|
|
16
|
+
utc_tooltip: "The times displayed are in {{utc}}",
|
|
17
17
|
};
|
|
@@ -3,8 +3,9 @@ import { IModel } from "../../qrvey/interfaces/IModel";
|
|
|
3
3
|
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
4
4
|
/**
|
|
5
5
|
* Gets the timezone object by the given argument or the model object
|
|
6
|
+
* - In any case, the offset is prioritized to override other properties.
|
|
6
7
|
* @param {IDTimezone} timezone the timezone object
|
|
7
8
|
* @param {IModel | IDataset} model the info of the dataset (model)
|
|
8
9
|
* @returns a new timezone object
|
|
9
10
|
*/
|
|
10
|
-
export declare function getTimezoneObject(timezone: IDTimezone, model
|
|
11
|
+
export declare function getTimezoneObject(timezone: IDTimezone, model?: IModel | IDataset): IDTimezone;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
2
|
import { TIMEZONE_TYPE } from "../constants/TIMEZONE_TYPE";
|
|
3
3
|
import { getTimezoneOffsetByType } from "./getTimezoneOffsetByType";
|
|
4
|
+
import { getUTCFormatByOffset } from "./getUTCFormatByOffset";
|
|
4
5
|
import { isValidISOOffset } from "./isValidISOOffset";
|
|
5
6
|
/**
|
|
6
7
|
* Gets the timezone object by the given argument or the model object
|
|
8
|
+
* - In any case, the offset is prioritized to override other properties.
|
|
7
9
|
* @param {IDTimezone} timezone the timezone object
|
|
8
10
|
* @param {IModel | IDataset} model the info of the dataset (model)
|
|
9
11
|
* @returns a new timezone object
|
|
@@ -11,11 +13,23 @@ import { isValidISOOffset } from "./isValidISOOffset";
|
|
|
11
13
|
export function getTimezoneObject(timezone, model) {
|
|
12
14
|
const offset = getOffset(timezone, model);
|
|
13
15
|
const type = getType(timezone, model, offset);
|
|
16
|
+
const resultingOffset = getTimezoneOffsetByType({ offset, type });
|
|
17
|
+
const utc = getUTC({ offset: resultingOffset, type });
|
|
14
18
|
return {
|
|
15
|
-
offset:
|
|
19
|
+
offset: resultingOffset,
|
|
16
20
|
type,
|
|
21
|
+
utc,
|
|
17
22
|
};
|
|
18
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the offset of the timezone by the given objects
|
|
26
|
+
* - Searchs the first argument
|
|
27
|
+
* - If the timezone is empty, in the model timezone is searched
|
|
28
|
+
* - If it does not exist in any, a default one is set.
|
|
29
|
+
* @param {IDTimezone} timezone The timezone object
|
|
30
|
+
* @param {IModel | IDataset} model The model info
|
|
31
|
+
* @returns {IDTimezoneOffset} the offset of the objects
|
|
32
|
+
*/
|
|
19
33
|
function getOffset(timezone, model) {
|
|
20
34
|
var _a;
|
|
21
35
|
let offset;
|
|
@@ -30,12 +44,26 @@ function getOffset(timezone, model) {
|
|
|
30
44
|
}
|
|
31
45
|
return offset;
|
|
32
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Gets the type of the timezone
|
|
49
|
+
* - Searchs the first argument
|
|
50
|
+
* - If it does not exist, asking for the timezone offset in order to prioritized the offset above all.
|
|
51
|
+
* - If the timezone is empty, in the model timezone is searched.
|
|
52
|
+
* - If it does not exist in any, a default one is set.
|
|
53
|
+
* @param {IDTimezone} timezone The timezone object
|
|
54
|
+
* @param {IModel | IDataset} model The model info
|
|
55
|
+
* @param {IDTimezoneOffset} offset a default offset if the validation are not satisfied
|
|
56
|
+
* @returns {IDTimezoneType} the rigth type of the timezone
|
|
57
|
+
*/
|
|
33
58
|
function getType(timezone, model, offset) {
|
|
34
59
|
var _a;
|
|
35
60
|
let type;
|
|
36
61
|
if (!isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.type)) {
|
|
37
62
|
type = timezone.type;
|
|
38
63
|
}
|
|
64
|
+
else if (!isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.offset)) {
|
|
65
|
+
type = getTypeByOffset(timezone === null || timezone === void 0 ? void 0 : timezone.offset);
|
|
66
|
+
}
|
|
39
67
|
else if (!isEmpty((_a = model === null || model === void 0 ? void 0 : model.timezone) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
40
68
|
type = model.timezone.type;
|
|
41
69
|
}
|
|
@@ -44,6 +72,15 @@ function getType(timezone, model, offset) {
|
|
|
44
72
|
}
|
|
45
73
|
return type;
|
|
46
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets the type by a offset
|
|
77
|
+
* - For a offset=0 the type is default
|
|
78
|
+
* - For a offset="browser" the type is browser
|
|
79
|
+
* - For a valid offset different to previous ones, the type is fixed;
|
|
80
|
+
* - Anything else, it is considered default.
|
|
81
|
+
* @param {IDTimezoneOffset} offset a given offset
|
|
82
|
+
* @returns {IDTimezoneType} the right timezone type for the offset
|
|
83
|
+
*/
|
|
47
84
|
function getTypeByOffset(offset) {
|
|
48
85
|
if (offset === "+00:00") {
|
|
49
86
|
return TIMEZONE_TYPE.DEFAULT;
|
|
@@ -56,3 +93,11 @@ function getTypeByOffset(offset) {
|
|
|
56
93
|
}
|
|
57
94
|
return TIMEZONE_TYPE.DEFAULT;
|
|
58
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the UTC string by the timezone object
|
|
98
|
+
* @param {IDTimezone} timezone the timezone object
|
|
99
|
+
* @returns {string} the label of the UTC value
|
|
100
|
+
*/
|
|
101
|
+
function getUTC(timezone) {
|
|
102
|
+
return getUTCFormatByOffset(timezone);
|
|
103
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { numericOffsetToISO } from "../adapters/numericOffsetToISO";
|
|
2
|
-
import { getTimezoneObject } from "./getTimezoneObject";
|
|
3
2
|
/**
|
|
4
3
|
* Gets the UTC format dependeing on the given offset
|
|
5
4
|
* @param {IDTimezone} timezone the timezone object
|
|
6
5
|
* @returns {string} an string with the UTC format
|
|
7
6
|
*/
|
|
8
7
|
export function getUTCFormatByOffset(timezone) {
|
|
9
|
-
|
|
10
|
-
let newOffset = numericOffsetToISO(newTimezone === null || newTimezone === void 0 ? void 0 : newTimezone.offset, false);
|
|
8
|
+
let newOffset = numericOffsetToISO(timezone === null || timezone === void 0 ? void 0 : timezone.offset, false);
|
|
11
9
|
if (newOffset.search(":0") > -1) {
|
|
12
10
|
newOffset = newOffset.slice(0, newOffset.indexOf(":"));
|
|
13
11
|
}
|
|
@@ -10,5 +10,5 @@ export const I18N_RELATIVE_CONTAINER = {
|
|
|
10
10
|
starting_date_tooltip: "The relative date will include the specific starting date and a period of time to show from that date onwards (Inclusive range). <br/> Unchecking this option will exclude the chosen starting date (exclusive range) from the date range.",
|
|
11
11
|
starting_from: "Starting From",
|
|
12
12
|
set_current_date: "Set to current date",
|
|
13
|
-
utc_tooltip: "The times displayed are in
|
|
13
|
+
utc_tooltip: "The times displayed are in {{utc}}",
|
|
14
14
|
};
|