@qrvey/utils 1.10.0-timezone-1 → 1.10.0
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/README.md +1618 -952
- package/dist/cjs/columns/constants/COLUMN_PROPERTIES.d.ts +1 -1
- package/dist/cjs/columns/constants/COLUMN_PROPERTY_LABEL.d.ts +1 -0
- package/dist/cjs/columns/constants/COMPOUND_COLUMN_PROPERTY_LABEL.d.ts +1 -0
- package/dist/cjs/columns/constants/COMPOUND_COLUMN_PROPERTY_LABEL.js +1 -0
- package/dist/cjs/columns/helpers/isNumericalColumn.js +3 -1
- package/dist/cjs/dates/adapters/ISOToNumericOffset.js +6 -1
- package/dist/cjs/dates/adapters/dateToHms.js +5 -7
- package/dist/cjs/dates/adapters/dateToMdyDate.d.ts +2 -1
- package/dist/cjs/dates/adapters/dateToMdyDate.js +9 -3
- package/dist/cjs/dates/adapters/dateToMonthYear.d.ts +2 -1
- package/dist/cjs/dates/adapters/dateToMonthYear.js +6 -2
- package/dist/cjs/dates/adapters/dateToQuarterYear.d.ts +2 -1
- package/dist/cjs/dates/adapters/dateToQuarterYear.js +6 -2
- package/dist/cjs/dates/adapters/dateToWeekYear.d.ts +2 -1
- package/dist/cjs/dates/adapters/dateToWeekYear.js +6 -2
- package/dist/cjs/dates/adapters/dateToYear.d.ts +2 -1
- package/dist/cjs/dates/adapters/dateToYear.js +6 -2
- package/dist/cjs/dates/adapters/hmsToDate.d.ts +2 -1
- package/dist/cjs/dates/adapters/hmsToDate.js +6 -2
- package/dist/cjs/dates/adapters/mdyDateToDate.d.ts +2 -1
- package/dist/cjs/dates/adapters/mdyDateToDate.js +7 -2
- package/dist/cjs/dates/adapters/monthYearToDate.d.ts +2 -1
- package/dist/cjs/dates/adapters/monthYearToDate.js +6 -2
- package/dist/cjs/dates/adapters/numericOffsetToISO.d.ts +1 -1
- package/dist/cjs/dates/adapters/numericOffsetToISO.js +15 -8
- package/dist/cjs/dates/adapters/quarterYearToDate.d.ts +2 -1
- package/dist/cjs/dates/adapters/quarterYearToDate.js +6 -2
- package/dist/cjs/dates/adapters/weekYearToDate.d.ts +2 -1
- package/dist/cjs/dates/adapters/weekYearToDate.js +6 -2
- package/dist/cjs/dates/adapters/yearToDate.d.ts +2 -1
- package/dist/cjs/dates/adapters/yearToDate.js +6 -2
- package/dist/cjs/dates/constants/TIMEZONE_TYPE.d.ts +5 -0
- package/dist/cjs/dates/constants/TIMEZONE_TYPE.js +9 -0
- package/dist/cjs/dates/helpers/getDateByDateFormat.d.ts +2 -1
- package/dist/cjs/dates/helpers/getDateByDateFormat.js +6 -6
- package/dist/cjs/dates/helpers/getDateByTimezone.d.ts +3 -3
- package/dist/cjs/dates/helpers/getDateByTimezone.js +12 -27
- package/dist/cjs/dates/helpers/getDateByTimezoneOffset.d.ts +1 -1
- package/dist/cjs/dates/helpers/getDateByTimezoneOffset.js +14 -6
- package/dist/cjs/dates/helpers/getDefaultDateSettings.d.ts +7 -0
- package/dist/cjs/dates/helpers/getDefaultDateSettings.js +17 -0
- package/dist/cjs/dates/helpers/getFormattedDateByFormat.d.ts +2 -1
- package/dist/cjs/dates/helpers/getFormattedDateByFormat.js +7 -7
- package/dist/cjs/dates/helpers/getTimezoneObject.d.ts +8 -1
- package/dist/cjs/dates/helpers/getTimezoneObject.js +98 -14
- package/dist/cjs/dates/helpers/getTimezoneOffsetByType.d.ts +13 -0
- package/dist/cjs/dates/helpers/getTimezoneOffsetByType.js +27 -0
- 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 +4 -1
- package/dist/cjs/dates/helpers/index.js +4 -1
- package/dist/cjs/dates/helpers/isValidPotentialDate.d.ts +1 -0
- package/dist/cjs/dates/helpers/isValidPotentialDate.js +14 -5
- package/dist/cjs/dates/interfaces/IBTimezone.d.ts +7 -0
- package/dist/cjs/dates/interfaces/IBTimezoneType.d.ts +2 -0
- package/dist/cjs/dates/interfaces/IDFDateToHmsSettings.d.ts +2 -1
- package/dist/cjs/dates/interfaces/IDTimezone.d.ts +3 -0
- package/dist/cjs/dates/interfaces/IDTimezoneType.d.ts +2 -0
- package/dist/cjs/dates/interfaces/IDTimezoneType.js +2 -0
- package/dist/cjs/dates/interfaces/IDateSettings.d.ts +5 -0
- package/dist/cjs/dates/interfaces/IDateSettings.js +2 -0
- package/dist/cjs/dates/interfaces/index.d.ts +4 -1
- package/dist/cjs/dates/interfaces/index.js +4 -1
- package/dist/cjs/filters/services/Filters.api.js +1 -1
- package/dist/cjs/format/format.js +11 -0
- package/dist/cjs/format/localization.js +10 -1
- package/dist/cjs/general/array/getArrayByProperty.d.ts +1 -1
- package/dist/cjs/general/array/getUniqueArray.d.ts +1 -1
- package/dist/cjs/general/array/getUniqueArray.js +2 -0
- package/dist/cjs/general/mix/isEmpty.js +2 -0
- package/dist/cjs/general/mix/isNaNV2.d.ts +1 -0
- package/dist/cjs/general/mix/isNaNV2.js +7 -2
- package/dist/cjs/general/numeric/getSign.js +1 -1
- package/dist/cjs/general/object/applyTimezoneDeep.d.ts +1 -1
- package/dist/cjs/general/object/applyTimezoneDeep.js +17 -12
- package/dist/cjs/general/object/isObject.js +3 -1
- package/dist/cjs/general/object/mergeDeep.d.ts +6 -0
- package/dist/cjs/general/object/mergeDeep.js +12 -10
- package/dist/cjs/general/object/objectCopy.d.ts +1 -1
- package/dist/cjs/general/object/removeUndefinedDeep.js +6 -3
- package/dist/cjs/general/string/padLeadingZeros.d.ts +28 -1
- package/dist/cjs/general/string/padLeadingZeros.js +75 -7
- package/dist/cjs/globalization/interfaces/common/II18nColumnProperties.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/dashboard/II18nDashboardToast.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/dashboard/II18nDashboardTooltips.d.ts +1 -0
- package/dist/cjs/globalization/labels/common/I18N_COLUMN_PROPERTY_LABEL.js +1 -0
- package/dist/cjs/globalization/labels/dashboard/I18N_DASHBOARD.js +2 -0
- package/dist/cjs/globalization/labels/filters/I18N_RELATIVE_CONTAINER.js +1 -1
- package/dist/cjs/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +5 -5
- package/dist/cjs/globalization/labels/panel/I18N_PANEL.js +1 -1
- package/dist/cjs/interfaces/format/IFormatConfig.Interface.d.ts +1 -1
- package/dist/cjs/qrvey/helpers/transformValue.js +35 -14
- package/dist/cjs/qrvey/interfaces/IBDataset.d.ts +1 -1
- package/dist/cjs/qrvey/interfaces/IBModel.d.ts +4 -1
- package/dist/cjs/qrvey/interfaces/index.d.ts +0 -1
- package/dist/cjs/qrvey/interfaces/index.js +0 -1
- package/dist/cjs/services/adapters/BTimezoneToUITimezone.d.ts +6 -1
- package/dist/cjs/services/adapters/BTimezoneToUITimezone.js +10 -1
- package/dist/columns/constants/COLUMN_PROPERTIES.d.ts +1 -1
- package/dist/columns/constants/COLUMN_PROPERTY_LABEL.d.ts +1 -0
- package/dist/columns/constants/COMPOUND_COLUMN_PROPERTY_LABEL.d.ts +1 -0
- package/dist/columns/constants/COMPOUND_COLUMN_PROPERTY_LABEL.js +1 -0
- package/dist/columns/helpers/isNumericalColumn.js +3 -1
- package/dist/dates/adapters/ISOToNumericOffset.js +6 -1
- package/dist/dates/adapters/dateToHms.js +5 -7
- package/dist/dates/adapters/dateToMdyDate.d.ts +2 -1
- package/dist/dates/adapters/dateToMdyDate.js +9 -3
- package/dist/dates/adapters/dateToMonthYear.d.ts +2 -1
- package/dist/dates/adapters/dateToMonthYear.js +6 -2
- package/dist/dates/adapters/dateToQuarterYear.d.ts +2 -1
- package/dist/dates/adapters/dateToQuarterYear.js +6 -2
- package/dist/dates/adapters/dateToWeekYear.d.ts +2 -1
- package/dist/dates/adapters/dateToWeekYear.js +6 -2
- package/dist/dates/adapters/dateToYear.d.ts +2 -1
- package/dist/dates/adapters/dateToYear.js +6 -2
- package/dist/dates/adapters/hmsToDate.d.ts +2 -1
- package/dist/dates/adapters/hmsToDate.js +6 -2
- package/dist/dates/adapters/mdyDateToDate.d.ts +2 -1
- package/dist/dates/adapters/mdyDateToDate.js +7 -2
- package/dist/dates/adapters/monthYearToDate.d.ts +2 -1
- package/dist/dates/adapters/monthYearToDate.js +6 -2
- package/dist/dates/adapters/numericOffsetToISO.d.ts +1 -1
- package/dist/dates/adapters/numericOffsetToISO.js +15 -8
- package/dist/dates/adapters/quarterYearToDate.d.ts +2 -1
- package/dist/dates/adapters/quarterYearToDate.js +6 -2
- package/dist/dates/adapters/weekYearToDate.d.ts +2 -1
- package/dist/dates/adapters/weekYearToDate.js +6 -2
- package/dist/dates/adapters/yearToDate.d.ts +2 -1
- package/dist/dates/adapters/yearToDate.js +6 -2
- package/dist/dates/constants/TIMEZONE_TYPE.d.ts +5 -0
- package/dist/dates/constants/TIMEZONE_TYPE.js +6 -0
- package/dist/dates/helpers/getDateByDateFormat.d.ts +2 -1
- package/dist/dates/helpers/getDateByDateFormat.js +6 -6
- package/dist/dates/helpers/getDateByTimezone.d.ts +3 -3
- package/dist/dates/helpers/getDateByTimezone.js +12 -27
- package/dist/dates/helpers/getDateByTimezoneOffset.d.ts +1 -1
- package/dist/dates/helpers/getDateByTimezoneOffset.js +11 -6
- package/dist/dates/helpers/getDefaultDateSettings.d.ts +7 -0
- package/dist/dates/helpers/getDefaultDateSettings.js +13 -0
- package/dist/dates/helpers/getFormattedDateByFormat.d.ts +2 -1
- package/dist/dates/helpers/getFormattedDateByFormat.js +7 -7
- package/dist/dates/helpers/getTimezoneObject.d.ts +8 -1
- package/dist/dates/helpers/getTimezoneObject.js +97 -13
- package/dist/dates/helpers/getTimezoneOffsetByType.d.ts +13 -0
- package/dist/dates/helpers/getTimezoneOffsetByType.js +23 -0
- package/dist/dates/helpers/getUTCFormatByOffset.d.ts +7 -0
- package/dist/dates/helpers/getUTCFormatByOffset.js +15 -0
- package/dist/dates/helpers/index.d.ts +4 -1
- package/dist/dates/helpers/index.js +4 -1
- package/dist/dates/helpers/isValidPotentialDate.d.ts +1 -0
- package/dist/dates/helpers/isValidPotentialDate.js +14 -5
- package/dist/dates/interfaces/IBTimezone.d.ts +7 -0
- package/dist/dates/interfaces/IBTimezoneType.d.ts +2 -0
- package/dist/dates/interfaces/IDFDateToHmsSettings.d.ts +2 -1
- package/dist/dates/interfaces/IDTimezone.d.ts +3 -0
- package/dist/dates/interfaces/IDTimezoneType.d.ts +2 -0
- package/dist/dates/interfaces/IDTimezoneType.js +1 -0
- package/dist/dates/interfaces/IDateSettings.d.ts +5 -0
- package/dist/dates/interfaces/IDateSettings.js +1 -0
- package/dist/dates/interfaces/index.d.ts +4 -1
- package/dist/dates/interfaces/index.js +4 -1
- package/dist/filters/services/Filters.api.js +1 -1
- package/dist/format/format.js +11 -0
- package/dist/format/localization.js +10 -1
- package/dist/general/array/getArrayByProperty.d.ts +1 -1
- package/dist/general/array/getUniqueArray.d.ts +1 -1
- package/dist/general/array/getUniqueArray.js +2 -0
- package/dist/general/mix/isEmpty.js +2 -0
- package/dist/general/mix/isNaNV2.d.ts +1 -0
- package/dist/general/mix/isNaNV2.js +7 -2
- package/dist/general/numeric/getSign.js +1 -1
- package/dist/general/object/applyTimezoneDeep.d.ts +1 -1
- package/dist/general/object/applyTimezoneDeep.js +17 -12
- package/dist/general/object/isObject.js +3 -1
- package/dist/general/object/mergeDeep.d.ts +6 -0
- package/dist/general/object/mergeDeep.js +12 -10
- package/dist/general/object/objectCopy.d.ts +1 -1
- package/dist/general/object/removeUndefinedDeep.js +6 -3
- package/dist/general/string/padLeadingZeros.d.ts +28 -1
- package/dist/general/string/padLeadingZeros.js +75 -7
- package/dist/globalization/interfaces/common/II18nColumnProperties.d.ts +1 -0
- package/dist/globalization/interfaces/dashboard/II18nDashboardToast.d.ts +1 -0
- package/dist/globalization/interfaces/dashboard/II18nDashboardTooltips.d.ts +1 -0
- package/dist/globalization/labels/common/I18N_COLUMN_PROPERTY_LABEL.js +1 -0
- package/dist/globalization/labels/dashboard/I18N_DASHBOARD.js +2 -0
- package/dist/globalization/labels/filters/I18N_RELATIVE_CONTAINER.js +1 -1
- package/dist/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +5 -5
- package/dist/globalization/labels/panel/I18N_PANEL.js +1 -1
- package/dist/interfaces/format/IFormatConfig.Interface.d.ts +1 -1
- package/dist/qrvey/helpers/transformValue.js +35 -14
- package/dist/qrvey/interfaces/IBDataset.d.ts +1 -1
- package/dist/qrvey/interfaces/IBModel.d.ts +4 -1
- package/dist/qrvey/interfaces/index.d.ts +0 -1
- package/dist/qrvey/interfaces/index.js +0 -1
- package/dist/services/adapters/BTimezoneToUITimezone.d.ts +6 -1
- package/dist/services/adapters/BTimezoneToUITimezone.js +10 -1
- package/package.json +4 -3
- package/dist/cjs/dates/interfaces/IGetDateByTimezoneSettings.d.ts +0 -6
- package/dist/cjs/qrvey/interfaces/IBTimezone.d.ts +0 -4
- package/dist/dates/interfaces/IGetDateByTimezoneSettings.d.ts +0 -6
- package/dist/qrvey/interfaces/IBTimezone.d.ts +0 -4
- /package/dist/cjs/{qrvey → dates}/interfaces/IBTimezone.js +0 -0
- /package/dist/cjs/dates/interfaces/{IGetDateByTimezoneSettings.js → IBTimezoneType.js} +0 -0
- /package/dist/{qrvey → dates}/interfaces/IBTimezone.js +0 -0
- /package/dist/dates/interfaces/{IGetDateByTimezoneSettings.js → IBTimezoneType.js} +0 -0
|
@@ -11,21 +11,21 @@ import { mdyDateToDate } from "../adapters/mdyDateToDate";
|
|
|
11
11
|
* @param time flag to convert the formatted date to miliseconds
|
|
12
12
|
* @returns a Date object, milisecond time or the same value if date format does not match.
|
|
13
13
|
*/
|
|
14
|
-
export function getDateByDateFormat(date, format,
|
|
14
|
+
export function getDateByDateFormat(date, format, settings) {
|
|
15
15
|
switch (format) {
|
|
16
16
|
case DATE_FORMAT.YEAR:
|
|
17
|
-
return yearToDate(date,
|
|
17
|
+
return yearToDate(date, settings);
|
|
18
18
|
case DATE_FORMAT.MONTH:
|
|
19
|
-
return monthYearToDate(date,
|
|
19
|
+
return monthYearToDate(date, settings);
|
|
20
20
|
case DATE_FORMAT.QUARTER:
|
|
21
|
-
return quarterYearToDate(date,
|
|
21
|
+
return quarterYearToDate(date, settings);
|
|
22
22
|
case DATE_FORMAT.WEEK:
|
|
23
|
-
return weekYearToDate(date,
|
|
23
|
+
return weekYearToDate(date, settings);
|
|
24
24
|
case DATE_FORMAT.DAY:
|
|
25
25
|
case DATE_FORMAT.HOUR:
|
|
26
26
|
case DATE_FORMAT.MINUTE:
|
|
27
27
|
case DATE_FORMAT.SECOND:
|
|
28
|
-
return mdyDateToDate(date,
|
|
28
|
+
return mdyDateToDate(date, settings);
|
|
29
29
|
default:
|
|
30
30
|
return date;
|
|
31
31
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
2
2
|
/**
|
|
3
3
|
* Gets a date value in the given timezone
|
|
4
4
|
* @param {string} date the date
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {IDTimezone} timezone the timezone object
|
|
6
6
|
* @returns {string} A transformed value
|
|
7
7
|
*/
|
|
8
|
-
export declare function getDateByTimezone(date: string,
|
|
8
|
+
export declare function getDateByTimezone(date: string | number | Date, timezone: IDTimezone): string | number | Date;
|
|
@@ -1,35 +1,20 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
-
import {
|
|
3
|
-
import { getDateByDateFormat } from "./getDateByDateFormat";
|
|
2
|
+
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
3
|
import { getDateByTimezoneOffset } from "./getDateByTimezoneOffset";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { getTimezoneObject } from "./getTimezoneObject";
|
|
5
|
+
import { isValidPotentialDate } from "./isValidPotentialDate";
|
|
6
|
+
import { validateDate } from "./validateDate";
|
|
7
7
|
/**
|
|
8
8
|
* Gets a date value in the given timezone
|
|
9
9
|
* @param {string} date the date
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {IDTimezone} timezone the timezone object
|
|
11
11
|
* @returns {string} A transformed value
|
|
12
12
|
*/
|
|
13
|
-
export function getDateByTimezone(date,
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!isEmpty(defaultSettings.timezone.offset) && isDateTime) {
|
|
21
|
-
const dateFormat = getDateFormatByProperty(defaultSettings.property);
|
|
22
|
-
const formattedDate = getDateByDateFormat(date, dateFormat);
|
|
23
|
-
const timezonedDate = getDateByTimezoneOffset(formattedDate, defaultSettings.timezone.offset);
|
|
24
|
-
return getFormattedDateByFormat(timezonedDate, dateFormat);
|
|
25
|
-
}
|
|
26
|
-
return date;
|
|
27
|
-
}
|
|
28
|
-
function getDefaultSettings(settings) {
|
|
29
|
-
return {
|
|
30
|
-
property: settings.property,
|
|
31
|
-
timezone: (settings === null || settings === void 0 ? void 0 : settings.timezone) || {
|
|
32
|
-
offset: undefined,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
13
|
+
export function getDateByTimezone(date, timezone) {
|
|
14
|
+
const defaultTimezone = getTimezoneObject(timezone);
|
|
15
|
+
if (isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.offset) ||
|
|
16
|
+
!isValidPotentialDate(date) ||
|
|
17
|
+
(typeof date === "string" && !validateDate(date, DATE_FORMAT.SECOND)))
|
|
18
|
+
return date;
|
|
19
|
+
return getDateByTimezoneOffset(date, defaultTimezone.offset);
|
|
35
20
|
}
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @param date String, object or millisencond number of the date
|
|
5
5
|
* @returns updated Date object
|
|
6
6
|
*/
|
|
7
|
-
export declare function getDateByTimezoneOffset(date: string | Date | number, offset?: number | string): Date;
|
|
7
|
+
export declare function getDateByTimezoneOffset(date: string | Date | number, offset?: number | string): string | Date | number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
2
|
import { ISOToNumericOffset } from "../adapters/ISOToNumericOffset";
|
|
3
3
|
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
4
|
import { isValidPotentialDate } from "./isValidPotentialDate";
|
|
@@ -11,11 +11,16 @@ import { validateDate } from "./validateDate";
|
|
|
11
11
|
*/
|
|
12
12
|
export function getDateByTimezoneOffset(date, offset) {
|
|
13
13
|
if (!isValidPotentialDate(date) ||
|
|
14
|
-
(typeof date === "string" && !validateDate(date, DATE_FORMAT.
|
|
14
|
+
(typeof date === "string" && !validateDate(date, DATE_FORMAT.SECOND)))
|
|
15
15
|
return date;
|
|
16
16
|
const dt = new Date(date.valueOf());
|
|
17
|
-
const newOffset =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const newOffset = ISOToNumericOffset(offset);
|
|
18
|
+
const timezonedDate = new Date(+dt + newOffset * 1000 * 60);
|
|
19
|
+
if (typeof date === "string") {
|
|
20
|
+
return dayjs(timezonedDate).format(DATE_FORMAT.SECOND);
|
|
21
|
+
}
|
|
22
|
+
else if (typeof date === "number") {
|
|
23
|
+
return +timezonedDate;
|
|
24
|
+
}
|
|
25
|
+
return timezonedDate;
|
|
21
26
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the default properties for Date Settings object
|
|
4
|
+
* @param settings the date settings
|
|
5
|
+
* @returns a new object with the date settings.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDefaultDateSettings(settings: IDateSettings): IDateSettings;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getTimezoneObject } from "./getTimezoneObject";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the default properties for Date Settings object
|
|
4
|
+
* @param settings the date settings
|
|
5
|
+
* @returns a new object with the date settings.
|
|
6
|
+
*/
|
|
7
|
+
export function getDefaultDateSettings(settings) {
|
|
8
|
+
var _a;
|
|
9
|
+
return {
|
|
10
|
+
convertMiliseconds: (_a = settings === null || settings === void 0 ? void 0 : settings.convertMiliseconds) !== null && _a !== void 0 ? _a : false,
|
|
11
|
+
timezone: getTimezoneObject(settings === null || settings === void 0 ? void 0 : settings.timezone),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IDateFormat } from "../interfaces/IDateFormat";
|
|
2
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
2
3
|
/**
|
|
3
4
|
* A Date object, string or millisecond number are gotten in order to convert it in an formatted string date
|
|
4
5
|
* - Some strings are valid
|
|
@@ -6,4 +7,4 @@ import { IDateFormat } from "../interfaces/IDateFormat";
|
|
|
6
7
|
* @param format The date format
|
|
7
8
|
* @returns a formmatted date or the same value if format does not match
|
|
8
9
|
*/
|
|
9
|
-
export declare function getFormattedDateByFormat(date: string | Date | number, format: IDateFormat): string | Date | number;
|
|
10
|
+
export declare function getFormattedDateByFormat(date: string | Date | number, format: IDateFormat, settings?: IDateSettings): string | Date | number;
|
|
@@ -11,22 +11,22 @@ import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
|
11
11
|
* @param format The date format
|
|
12
12
|
* @returns a formmatted date or the same value if format does not match
|
|
13
13
|
*/
|
|
14
|
-
export function getFormattedDateByFormat(date, format) {
|
|
14
|
+
export function getFormattedDateByFormat(date, format, settings) {
|
|
15
15
|
switch (format) {
|
|
16
16
|
case DATE_FORMAT.YEAR:
|
|
17
|
-
return dateToYear(date);
|
|
17
|
+
return dateToYear(date, settings);
|
|
18
18
|
case DATE_FORMAT.MONTH:
|
|
19
|
-
return dateToMonthYear(date);
|
|
19
|
+
return dateToMonthYear(date, settings);
|
|
20
20
|
case DATE_FORMAT.QUARTER:
|
|
21
|
-
return dateToQuarterYear(date);
|
|
21
|
+
return dateToQuarterYear(date, settings);
|
|
22
22
|
case DATE_FORMAT.WEEK:
|
|
23
|
-
return dateToWeekYear(date);
|
|
23
|
+
return dateToWeekYear(date, settings);
|
|
24
24
|
case DATE_FORMAT.DAY:
|
|
25
|
-
return dateToMdyDate(date);
|
|
25
|
+
return dateToMdyDate(date, settings);
|
|
26
26
|
case DATE_FORMAT.HOUR:
|
|
27
27
|
case DATE_FORMAT.MINUTE:
|
|
28
28
|
case DATE_FORMAT.SECOND:
|
|
29
|
-
return dateToMdyDate(date, true);
|
|
29
|
+
return dateToMdyDate(date, Object.assign(Object.assign({}, settings), { convertMiliseconds: true }));
|
|
30
30
|
default:
|
|
31
31
|
return date;
|
|
32
32
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
2
2
|
import { IModel } from "../../qrvey/interfaces/IModel";
|
|
3
3
|
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
4
|
-
|
|
4
|
+
/**
|
|
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.
|
|
7
|
+
* @param {IDTimezone} timezone the timezone object
|
|
8
|
+
* @param {IModel | IDataset} model the info of the dataset (model)
|
|
9
|
+
* @returns a new timezone object
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTimezoneObject(timezone: IDTimezone, model?: IModel | IDataset): IDTimezone;
|
|
@@ -1,20 +1,104 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
3
|
+
import { TIMEZONE_TYPE } from "../constants/TIMEZONE_TYPE";
|
|
4
|
+
import { getTimezoneOffsetByType } from "./getTimezoneOffsetByType";
|
|
5
|
+
import { getUTCFormatByOffset } from "./getUTCFormatByOffset";
|
|
6
|
+
import { isValidISOOffset } from "./isValidISOOffset";
|
|
7
|
+
/**
|
|
8
|
+
* Gets the timezone object by the given argument or the model object
|
|
9
|
+
* - In any case, the offset is prioritized to override other properties.
|
|
10
|
+
* @param {IDTimezone} timezone the timezone object
|
|
11
|
+
* @param {IModel | IDataset} model the info of the dataset (model)
|
|
12
|
+
* @returns a new timezone object
|
|
13
|
+
*/
|
|
2
14
|
export function getTimezoneObject(timezone, model) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
15
|
+
const offset = getOffset(timezone, model);
|
|
16
|
+
const type = getType(timezone, model, offset);
|
|
17
|
+
const resultingOffset = getTimezoneOffsetByType({ offset, type });
|
|
18
|
+
const utc = getUTC({ offset: resultingOffset, type });
|
|
19
|
+
return {
|
|
20
|
+
offset: resultingOffset,
|
|
21
|
+
type,
|
|
22
|
+
utc,
|
|
6
23
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gets the offset of the timezone by the given objects
|
|
27
|
+
* - Searchs the first argument
|
|
28
|
+
* - If the timezone is empty, in the model timezone is searched
|
|
29
|
+
* - If it does not exist in any, a default one is set.
|
|
30
|
+
* @param {IDTimezone} timezone The timezone object
|
|
31
|
+
* @param {IModel | IDataset} model The model info
|
|
32
|
+
* @returns {IDTimezoneOffset} the offset of the objects
|
|
33
|
+
*/
|
|
34
|
+
function getOffset(timezone, model) {
|
|
35
|
+
var _a;
|
|
36
|
+
let offset;
|
|
37
|
+
if (!isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.offset)) {
|
|
38
|
+
offset = timezone.offset;
|
|
39
|
+
}
|
|
40
|
+
else if (!isEmpty((_a = model === null || model === void 0 ? void 0 : model.timezone) === null || _a === void 0 ? void 0 : _a.offset)) {
|
|
41
|
+
offset = model.timezone.offset;
|
|
13
42
|
}
|
|
14
43
|
else {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
44
|
+
offset = "+00:00";
|
|
45
|
+
}
|
|
46
|
+
return offset;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Gets the type of the timezone
|
|
50
|
+
* - Searchs the first argument
|
|
51
|
+
* - If it does not exist, asking for the timezone offset in order to prioritized the offset above all.
|
|
52
|
+
* - If the timezone is empty, in the model timezone is searched.
|
|
53
|
+
* - If it does not exist in any, a default one is set.
|
|
54
|
+
* @param {IDTimezone} timezone The timezone object
|
|
55
|
+
* @param {IModel | IDataset} model The model info
|
|
56
|
+
* @param {IDTimezoneOffset} offset a default offset if the validation are not satisfied
|
|
57
|
+
* @returns {IDTimezoneType} the rigth type of the timezone
|
|
58
|
+
*/
|
|
59
|
+
function getType(timezone, model, offset) {
|
|
60
|
+
var _a;
|
|
61
|
+
let type;
|
|
62
|
+
if (!isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.type)) {
|
|
63
|
+
type = timezone.type;
|
|
64
|
+
}
|
|
65
|
+
else if (!isEmpty(timezone === null || timezone === void 0 ? void 0 : timezone.offset)) {
|
|
66
|
+
type = getTypeByOffset(timezone === null || timezone === void 0 ? void 0 : timezone.offset);
|
|
18
67
|
}
|
|
19
|
-
|
|
68
|
+
else if (!isEmpty((_a = model === null || model === void 0 ? void 0 : model.timezone) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
69
|
+
type = model.timezone.type;
|
|
70
|
+
}
|
|
71
|
+
if (isEmpty(type)) {
|
|
72
|
+
type = getTypeByOffset(offset);
|
|
73
|
+
}
|
|
74
|
+
return type;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the type by a offset
|
|
78
|
+
* - For a offset=0 the type is default
|
|
79
|
+
* - For a offset="browser" the type is browser
|
|
80
|
+
* - For a valid offset different to previous ones, the type is fixed;
|
|
81
|
+
* - Anything else, it is considered default.
|
|
82
|
+
* @param {IDTimezoneOffset} offset a given offset
|
|
83
|
+
* @returns {IDTimezoneType} the right timezone type for the offset
|
|
84
|
+
*/
|
|
85
|
+
function getTypeByOffset(offset) {
|
|
86
|
+
if (offset === "+00:00") {
|
|
87
|
+
return TIMEZONE_TYPE.DEFAULT;
|
|
88
|
+
}
|
|
89
|
+
else if (offset === "browser") {
|
|
90
|
+
return TIMEZONE_TYPE.BROWSER;
|
|
91
|
+
}
|
|
92
|
+
else if (isValidISOOffset(offset) || !isNaNV2(offset)) {
|
|
93
|
+
return TIMEZONE_TYPE.FIXED;
|
|
94
|
+
}
|
|
95
|
+
return TIMEZONE_TYPE.DEFAULT;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets the UTC string by the timezone object
|
|
99
|
+
* @param {IDTimezone} timezone the timezone object
|
|
100
|
+
* @returns {string} the label of the UTC value
|
|
101
|
+
*/
|
|
102
|
+
function getUTC(timezone) {
|
|
103
|
+
return getUTCFormatByOffset(timezone);
|
|
20
104
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IBTimezone } from "../interfaces/IBTimezone";
|
|
2
|
+
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
3
|
+
import { IDTimezoneOffset } from "../interfaces/IDTimezoneOffset";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the timezone offset by the timezone type.
|
|
6
|
+
* For browser types, it is calculated by a Date instance
|
|
7
|
+
* Default types is UTC-0
|
|
8
|
+
* Undefined or Fixed types is gotten by the offset property
|
|
9
|
+
* @param {IDTimezoneType} type the timezone type
|
|
10
|
+
* @param {IDTimezone | IBTimezone} timezone the timezone object
|
|
11
|
+
* @returns {IDTimezoneOffset} the offset of the timezone
|
|
12
|
+
*/
|
|
13
|
+
export declare function getTimezoneOffsetByType(timezone: IDTimezone | IBTimezone): IDTimezoneOffset;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
+
import { numericOffsetToISO } from "../adapters/numericOffsetToISO";
|
|
3
|
+
import { TIMEZONE_TYPE } from "../constants/TIMEZONE_TYPE";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the timezone offset by the timezone type.
|
|
6
|
+
* For browser types, it is calculated by a Date instance
|
|
7
|
+
* Default types is UTC-0
|
|
8
|
+
* Undefined or Fixed types is gotten by the offset property
|
|
9
|
+
* @param {IDTimezoneType} type the timezone type
|
|
10
|
+
* @param {IDTimezone | IBTimezone} timezone the timezone object
|
|
11
|
+
* @returns {IDTimezoneOffset} the offset of the timezone
|
|
12
|
+
*/
|
|
13
|
+
export function getTimezoneOffsetByType(timezone) {
|
|
14
|
+
if (isEmpty(timezone))
|
|
15
|
+
return "+00:00";
|
|
16
|
+
if (timezone.type === TIMEZONE_TYPE.BROWSER) {
|
|
17
|
+
return numericOffsetToISO("browser");
|
|
18
|
+
}
|
|
19
|
+
else if (timezone.type === TIMEZONE_TYPE.DEFAULT) {
|
|
20
|
+
return "+00:00";
|
|
21
|
+
}
|
|
22
|
+
return timezone.offset || timezone.numericOffset || "+00:00";
|
|
23
|
+
}
|
|
@@ -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, minified?: boolean): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isEmpty } from "../../general";
|
|
2
|
+
import { numericOffsetToISO } from "../adapters/numericOffsetToISO";
|
|
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, minified = false) {
|
|
9
|
+
const newMinified = !isEmpty(minified) && typeof minified === "boolean" ? minified : false;
|
|
10
|
+
let newOffset = numericOffsetToISO(timezone === null || timezone === void 0 ? void 0 : timezone.offset, !newMinified);
|
|
11
|
+
if (newMinified && newOffset.search(":00") > -1) {
|
|
12
|
+
newOffset = newOffset.slice(0, newOffset.indexOf(":"));
|
|
13
|
+
}
|
|
14
|
+
return `UTC${newOffset}`;
|
|
15
|
+
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
export * from "./areIncludedDateTokens";
|
|
2
2
|
export * from "./getDateByDateFormat";
|
|
3
3
|
export * from "./getDateByTimezone";
|
|
4
|
+
export * from "./getDateByTimezoneOffset";
|
|
4
5
|
export * from "./getDateFormatByProperty";
|
|
5
6
|
export * from "./getDateFormatRegularExpressionInArray";
|
|
6
7
|
export * from "./getDatePickerPickLevel";
|
|
7
8
|
export * from "./getDateRange";
|
|
9
|
+
export * from "./getDefaultDateSettings";
|
|
8
10
|
export * from "./getFormattedDateByFormat";
|
|
9
11
|
export * from "./getSeparatorByDateFormat";
|
|
10
12
|
export * from "./getTimezoneObject";
|
|
13
|
+
export * from "./getTimezoneOffsetByType";
|
|
14
|
+
export * from "./getUTCFormatByOffset";
|
|
11
15
|
export * from "./getWeek";
|
|
12
16
|
export * from "./isValidDateObject";
|
|
13
17
|
export * from "./isValidPotentialDate";
|
|
14
|
-
export * from "./getDateByTimezoneOffset";
|
|
15
18
|
export * from "./validateDate";
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
export * from "./areIncludedDateTokens";
|
|
2
2
|
export * from "./getDateByDateFormat";
|
|
3
3
|
export * from "./getDateByTimezone";
|
|
4
|
+
export * from "./getDateByTimezoneOffset";
|
|
4
5
|
export * from "./getDateFormatByProperty";
|
|
5
6
|
export * from "./getDateFormatRegularExpressionInArray";
|
|
6
7
|
export * from "./getDatePickerPickLevel";
|
|
7
8
|
export * from "./getDateRange";
|
|
9
|
+
export * from "./getDefaultDateSettings";
|
|
8
10
|
export * from "./getFormattedDateByFormat";
|
|
9
11
|
export * from "./getSeparatorByDateFormat";
|
|
10
12
|
export * from "./getTimezoneObject";
|
|
13
|
+
export * from "./getTimezoneOffsetByType";
|
|
14
|
+
export * from "./getUTCFormatByOffset";
|
|
11
15
|
export * from "./getWeek";
|
|
12
16
|
export * from "./isValidDateObject";
|
|
13
17
|
export * from "./isValidPotentialDate";
|
|
14
|
-
export * from "./getDateByTimezoneOffset";
|
|
15
18
|
export * from "./validateDate";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if the given date is allowed to continue the process for adapting dates
|
|
3
|
+
* - If the string is a token or a combination of tokens is not valid
|
|
3
4
|
* @param {string | Date | number} date String, object or millisencond number of the date
|
|
4
5
|
* @returns true: the date is valid.
|
|
5
6
|
*/
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
-
import {
|
|
2
|
+
import { DATE_FORMATS } from "../constants/DATE_FORMATS";
|
|
3
|
+
import { areIncludedDateTokens } from "./areIncludedDateTokens";
|
|
3
4
|
/**
|
|
4
5
|
* Checks if the given date is allowed to continue the process for adapting dates
|
|
6
|
+
* - If the string is a token or a combination of tokens is not valid
|
|
5
7
|
* @param {string | Date | number} date String, object or millisencond number of the date
|
|
6
8
|
* @returns true: the date is valid.
|
|
7
9
|
*/
|
|
8
10
|
export function isValidPotentialDate(date) {
|
|
9
11
|
return (!isEmpty(date) &&
|
|
10
|
-
!
|
|
11
|
-
((date
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
!includingDateTokens(date) &&
|
|
13
|
+
(isDateInstance(date) || isStringDate(date) || typeof date === "number"));
|
|
14
|
+
}
|
|
15
|
+
function includingDateTokens(date) {
|
|
16
|
+
return DATE_FORMATS.some((dateFormat) => areIncludedDateTokens(date, dateFormat));
|
|
17
|
+
}
|
|
18
|
+
function isDateInstance(date) {
|
|
19
|
+
return date instanceof Date && !isNaN(date);
|
|
20
|
+
}
|
|
21
|
+
function isStringDate(date) {
|
|
22
|
+
return (typeof date === "string" && new Date(date).toString() !== "Invalid Date");
|
|
14
23
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
export * from "./IBTimezone";
|
|
2
|
+
export * from "./IBTimezoneType";
|
|
1
3
|
export * from "./IDateFormat";
|
|
2
4
|
export * from "./IDateGroupingProperty";
|
|
5
|
+
export * from "./IDateSettings";
|
|
3
6
|
export * from "./IDFDateToHmsSettings";
|
|
4
7
|
export * from "./IDTimezone";
|
|
5
8
|
export * from "./IDTimezoneOffset";
|
|
6
|
-
export * from "./
|
|
9
|
+
export * from "./IDTimezoneType";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
export * from "./IBTimezone";
|
|
2
|
+
export * from "./IBTimezoneType";
|
|
1
3
|
export * from "./IDateFormat";
|
|
2
4
|
export * from "./IDateGroupingProperty";
|
|
5
|
+
export * from "./IDateSettings";
|
|
3
6
|
export * from "./IDFDateToHmsSettings";
|
|
4
7
|
export * from "./IDTimezone";
|
|
5
8
|
export * from "./IDTimezoneOffset";
|
|
6
|
-
export * from "./
|
|
9
|
+
export * from "./IDTimezoneType";
|
|
@@ -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) {
|
package/dist/format/format.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { format as d3Format } from "d3-format";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
import { DATEGROUP_FORMATTING_UNSUPPORT, appliesFormatting, hasfileSizeProperty, isTextColumn, DEFAULT_DATE, } from "./definition";
|
|
4
|
+
//* *dayjs plugins */
|
|
4
5
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
6
|
import advancedFormat from "dayjs/plugin/advancedFormat";
|
|
6
7
|
import utc from "dayjs/plugin/utc";
|
|
8
|
+
import weekYear from "dayjs/plugin/weekYear";
|
|
9
|
+
import weekOfYear from "dayjs/plugin/weekOfYear";
|
|
10
|
+
import updateLocale from "dayjs/plugin/updateLocale";
|
|
11
|
+
//* * end dayjs plugin imports */
|
|
7
12
|
import { isEmpty } from "../general/mix/isEmpty";
|
|
8
13
|
import { _get } from "../general/object/get";
|
|
9
14
|
import { COLUMN } from "../columns/constants/COLUMN";
|
|
@@ -12,9 +17,15 @@ import { formatWithLocale } from "./localization";
|
|
|
12
17
|
import { isObject } from "../general/object/isObject";
|
|
13
18
|
import { DURATION_PARTS_LIST } from "../column_format/constants/DURATION_PARTS_LIST";
|
|
14
19
|
import { cloneDeep } from "../general/object/cloneDeep";
|
|
20
|
+
dayjs.extend(updateLocale);
|
|
21
|
+
dayjs.updateLocale("en", {
|
|
22
|
+
yearStart: 4,
|
|
23
|
+
});
|
|
15
24
|
dayjs.extend(isoWeek); // Add support for iso week format https://github.com/iamkun/dayjs/issues/1328
|
|
16
25
|
dayjs.extend(advancedFormat); // Add support to advanced formats https://day.js.org/docs/en/plugin/advanced-format
|
|
17
26
|
dayjs.extend(utc);
|
|
27
|
+
dayjs.extend(weekYear);
|
|
28
|
+
dayjs.extend(weekOfYear);
|
|
18
29
|
/**
|
|
19
30
|
* Apply to the given date format to a date value
|
|
20
31
|
* @param bytes type number
|
|
@@ -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))
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @param property the property to get the value collection
|
|
5
5
|
* @returns a collection of values by property
|
|
6
6
|
*/
|
|
7
|
-
export declare function getArrayByProperty<T = any>(arr: T[], property: string): T[];
|
|
7
|
+
export declare function getArrayByProperty<T = any>(arr: T[], property: string | number): T[];
|