@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
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
2
|
-
import { IBTimezone } from "../../
|
|
2
|
+
import { IBTimezone } from "../../dates/interfaces/IBTimezone";
|
|
3
|
+
/**
|
|
4
|
+
* Transforms the backenc timezone structure to UI timezone structure
|
|
5
|
+
* @param {IBTimezone} timezone the backend timezone object
|
|
6
|
+
* @returns {IDTimezone} the UI timezone object
|
|
7
|
+
*/
|
|
3
8
|
export declare function BTimezoneToUITimezone(timezone: IBTimezone): IDTimezone;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BTimezoneToUITimezone = void 0;
|
|
4
|
+
const TIMEZONE_TYPE_1 = require("../../dates/constants/TIMEZONE_TYPE");
|
|
5
|
+
const getTimezoneOffsetByType_1 = require("../../dates/helpers/getTimezoneOffsetByType");
|
|
6
|
+
/**
|
|
7
|
+
* Transforms the backenc timezone structure to UI timezone structure
|
|
8
|
+
* @param {IBTimezone} timezone the backend timezone object
|
|
9
|
+
* @returns {IDTimezone} the UI timezone object
|
|
10
|
+
*/
|
|
4
11
|
function BTimezoneToUITimezone(timezone) {
|
|
12
|
+
const type = (timezone === null || timezone === void 0 ? void 0 : timezone.type) || TIMEZONE_TYPE_1.TIMEZONE_TYPE.DEFAULT;
|
|
5
13
|
return {
|
|
6
|
-
|
|
14
|
+
type,
|
|
15
|
+
offset: (0, getTimezoneOffsetByType_1.getTimezoneOffsetByType)(Object.assign(Object.assign({}, timezone), { type })),
|
|
7
16
|
};
|
|
8
17
|
}
|
|
9
18
|
exports.BTimezoneToUITimezone = BTimezoneToUITimezone;
|
|
@@ -2,4 +2,4 @@ import { COLUMN_PROPERTY } from "./COLUMN_PROPERTY";
|
|
|
2
2
|
/**
|
|
3
3
|
* @description Collection of column properties
|
|
4
4
|
*/
|
|
5
|
-
export declare const COLUMN_PROPERTIES: (import("
|
|
5
|
+
export declare const COLUMN_PROPERTIES: (import("./COMPOUND_COLUMN_PROPERTY").COMPOUND_COLUMN_PROPERTY | import("../..").DATE_GROUPING_PROPERTY | import("../..").DATE_GROUPING_TIME_PROPERTY | import("../..").DATE_DISTINCT_PROPERTY | import("../..").DATE_DISTINCT_TIME_PROPERTY | import("./COMPLEX_COLUMN_PROPERTY").COMPLEX_COLUMN_PROPERTY | COLUMN_PROPERTY)[];
|
|
@@ -13,6 +13,7 @@ export declare const COLUMN_PROPERTY_LABEL: {
|
|
|
13
13
|
ADDRESS_STATE: COMPOUND_COLUMN_PROPERTY_LABEL.ADDRESS_STATE;
|
|
14
14
|
ADDRESS_POSTAL: COMPOUND_COLUMN_PROPERTY_LABEL.ADDRESS_POSTAL;
|
|
15
15
|
ADDRESS_COUNTRY: COMPOUND_COLUMN_PROPERTY_LABEL.ADDRESS_COUNTRY;
|
|
16
|
+
ADDRESS_COUNTY: COMPOUND_COLUMN_PROPERTY_LABEL.ADDRESS_COUNTY;
|
|
16
17
|
USADDRESS_LINE_1: COMPOUND_COLUMN_PROPERTY_LABEL.USADDRESS_LINE_1;
|
|
17
18
|
USADDRESS_LINE_2: COMPOUND_COLUMN_PROPERTY_LABEL.USADDRESS_LINE_2;
|
|
18
19
|
USADDRESS_CITY: COMPOUND_COLUMN_PROPERTY_LABEL.ADDRESS_CITY;
|
|
@@ -6,6 +6,7 @@ export declare enum COMPOUND_COLUMN_PROPERTY_LABEL {
|
|
|
6
6
|
ADDRESS_STATE = "State/Region/Province",
|
|
7
7
|
ADDRESS_POSTAL = "Postal/Zip Code",
|
|
8
8
|
ADDRESS_COUNTRY = "Country",
|
|
9
|
+
ADDRESS_COUNTY = "County",
|
|
9
10
|
USADDRESS_LINE_1 = "Address 1",
|
|
10
11
|
USADDRESS_LINE_2 = "Address 2",
|
|
11
12
|
USADDRESS_CITY = "City",
|
|
@@ -7,6 +7,7 @@ export var COMPOUND_COLUMN_PROPERTY_LABEL;
|
|
|
7
7
|
COMPOUND_COLUMN_PROPERTY_LABEL["ADDRESS_STATE"] = "State/Region/Province";
|
|
8
8
|
COMPOUND_COLUMN_PROPERTY_LABEL["ADDRESS_POSTAL"] = "Postal/Zip Code";
|
|
9
9
|
COMPOUND_COLUMN_PROPERTY_LABEL["ADDRESS_COUNTRY"] = "Country";
|
|
10
|
+
COMPOUND_COLUMN_PROPERTY_LABEL["ADDRESS_COUNTY"] = "County";
|
|
10
11
|
COMPOUND_COLUMN_PROPERTY_LABEL["USADDRESS_LINE_1"] = "Address 1";
|
|
11
12
|
COMPOUND_COLUMN_PROPERTY_LABEL["USADDRESS_LINE_2"] = "Address 2";
|
|
12
13
|
COMPOUND_COLUMN_PROPERTY_LABEL["USADDRESS_CITY"] = "City";
|
|
@@ -11,4 +11,6 @@ import { NUMERICAL_COLUMNS } from "../constants/NUMERICAL_COLUMNS";
|
|
|
11
11
|
export const isNumericalColumn = (column) => !isEmpty(column) &&
|
|
12
12
|
isObject(column) &&
|
|
13
13
|
(NUMERICAL_COLUMNS.includes(column.type) ||
|
|
14
|
-
(column.type === COLUMN.FORMULA && column.formulaType === FORMULA.NUMBER)
|
|
14
|
+
(column.type === COLUMN.FORMULA && column.formulaType === FORMULA.NUMBER) ||
|
|
15
|
+
(column.type === COLUMN.AGGREGATED_FORMULA &&
|
|
16
|
+
column.formulaType === FORMULA.NUMBER));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
2
|
+
import { getSign } from "../../general/numeric/getSign";
|
|
2
3
|
import { isValidISOOffset } from "../helpers/isValidISOOffset";
|
|
3
4
|
/**
|
|
4
5
|
* Gets the numeric offset (minutes) from the ISO offset (string)
|
|
@@ -6,10 +7,14 @@ import { isValidISOOffset } from "../helpers/isValidISOOffset";
|
|
|
6
7
|
* @returns {number} the offset in minutes
|
|
7
8
|
*/
|
|
8
9
|
export function ISOToNumericOffset(offset) {
|
|
10
|
+
if (typeof offset === "string" && offset === "browser")
|
|
11
|
+
return -1 * new Date().getTimezoneOffset();
|
|
9
12
|
if (typeof offset === "number" || !isNaNV2(offset))
|
|
10
13
|
return +offset;
|
|
11
14
|
if (!isValidISOOffset(offset))
|
|
12
15
|
return 0;
|
|
13
16
|
const [hours, minutes] = offset.split(":").map(Number);
|
|
14
|
-
|
|
17
|
+
const sign = getSign(hours);
|
|
18
|
+
const absoluteOffset = Math.abs(hours) * 60 + minutes;
|
|
19
|
+
return sign === "-" ? -1 * absoluteOffset : absoluteOffset;
|
|
15
20
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { padLeadingZeros } from "../../general/string/padLeadingZeros";
|
|
2
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
2
3
|
import { isValidDateObject } from "../helpers/isValidDateObject";
|
|
3
4
|
import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
4
5
|
/**
|
|
@@ -10,10 +11,11 @@ import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
|
10
11
|
export function dateToHms(date, settings) {
|
|
11
12
|
if (!isValidPotentialDate(date))
|
|
12
13
|
return date;
|
|
13
|
-
const
|
|
14
|
+
const defaultSettings = getDefaultSettings(settings);
|
|
15
|
+
const timezonedDate = getDateByTimezone(date, defaultSettings.timezone);
|
|
16
|
+
const dt = new Date(timezonedDate.valueOf());
|
|
14
17
|
if (!isValidDateObject(dt))
|
|
15
18
|
return date;
|
|
16
|
-
const defaultSettings = getDefaultSettings(settings);
|
|
17
19
|
const hours = getHours(dt, defaultSettings);
|
|
18
20
|
const minutes = getMinutes(dt, defaultSettings);
|
|
19
21
|
const seconds = getSeconds(dt, defaultSettings);
|
|
@@ -26,11 +28,7 @@ export function dateToHms(date, settings) {
|
|
|
26
28
|
*/
|
|
27
29
|
function getDefaultSettings(settings) {
|
|
28
30
|
var _a, _b, _c;
|
|
29
|
-
return {
|
|
30
|
-
omitHour: (_a = settings === null || settings === void 0 ? void 0 : settings.omitHour) !== null && _a !== void 0 ? _a : false,
|
|
31
|
-
omitMinute: (_b = settings === null || settings === void 0 ? void 0 : settings.omitMinute) !== null && _b !== void 0 ? _b : false,
|
|
32
|
-
omitSecond: (_c = settings === null || settings === void 0 ? void 0 : settings.omitSecond) !== null && _c !== void 0 ? _c : false,
|
|
33
|
-
};
|
|
31
|
+
return Object.assign(Object.assign({}, settings), { omitHour: (_a = settings === null || settings === void 0 ? void 0 : settings.omitHour) !== null && _a !== void 0 ? _a : false, omitMinute: (_b = settings === null || settings === void 0 ? void 0 : settings.omitMinute) !== null && _b !== void 0 ? _b : false, omitSecond: (_c = settings === null || settings === void 0 ? void 0 : settings.omitSecond) !== null && _c !== void 0 ? _c : false });
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
34
|
* Gets the Hours
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transform a Date to [mm/dd/yyyy] date format.
|
|
3
4
|
* @param date String, object or millisencond number of the date
|
|
4
5
|
* @returns string of [mm/dd/yyyy] date format
|
|
5
6
|
*/
|
|
6
|
-
export declare function dateToMdyDate(date: string | Date | number,
|
|
7
|
+
export declare function dateToMdyDate(date: string | Date | number, settings?: IDateSettings): string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { padLeadingZeros } from "../../general/string/padLeadingZeros";
|
|
2
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
3
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
2
4
|
import { isValidDateObject } from "../helpers/isValidDateObject";
|
|
3
5
|
import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
4
6
|
import { dateToHms } from "./dateToHms";
|
|
@@ -7,11 +9,15 @@ import { dateToHms } from "./dateToHms";
|
|
|
7
9
|
* @param date String, object or millisencond number of the date
|
|
8
10
|
* @returns string of [mm/dd/yyyy] date format
|
|
9
11
|
*/
|
|
10
|
-
export function dateToMdyDate(date,
|
|
12
|
+
export function dateToMdyDate(date, settings) {
|
|
11
13
|
if (!isValidPotentialDate(date))
|
|
12
14
|
return date;
|
|
13
|
-
const
|
|
15
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
16
|
+
const timezonedDate = getDateByTimezone(date, defaultSettings.timezone);
|
|
17
|
+
const dt = new Date(timezonedDate.valueOf());
|
|
14
18
|
if (!isValidDateObject(dt))
|
|
15
19
|
return date;
|
|
16
|
-
return `${padLeadingZeros(dt.getMonth() + 1, 2).slice(-2)}/${padLeadingZeros(dt.getDate(), 2).slice(-2)}/${padLeadingZeros(dt.getFullYear(), 4)}${
|
|
20
|
+
return `${padLeadingZeros(dt.getMonth() + 1, 2).slice(-2)}/${padLeadingZeros(dt.getDate(), 2).slice(-2)}/${padLeadingZeros(dt.getFullYear(), 4)}${defaultSettings.convertMiliseconds
|
|
21
|
+
? ` ${dateToHms(timezonedDate, defaultSettings)}`
|
|
22
|
+
: ""}`;
|
|
17
23
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transform a Date to [Month Year] date format.
|
|
3
4
|
* @param date String, object or millisencond number of the date
|
|
4
5
|
* @returns string of [Month Year] date format
|
|
5
6
|
*/
|
|
6
|
-
export declare function dateToMonthYear(date: string | Date | number): string;
|
|
7
|
+
export declare function dateToMonthYear(date: string | Date | number, settings?: IDateSettings): string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DATE_YEAR_MONTHS } from "../constants/DATE_YEAR_MONTHS";
|
|
2
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
3
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
2
4
|
import { isValidDateObject } from "../helpers/isValidDateObject";
|
|
3
5
|
import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
4
6
|
/**
|
|
@@ -6,10 +8,12 @@ import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
|
6
8
|
* @param date String, object or millisencond number of the date
|
|
7
9
|
* @returns string of [Month Year] date format
|
|
8
10
|
*/
|
|
9
|
-
export function dateToMonthYear(date) {
|
|
11
|
+
export function dateToMonthYear(date, settings) {
|
|
10
12
|
if (!isValidPotentialDate(date))
|
|
11
13
|
return date;
|
|
12
|
-
const
|
|
14
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
15
|
+
const timezonedDate = getDateByTimezone(date, defaultSettings.timezone);
|
|
16
|
+
const dt = new Date(timezonedDate.valueOf());
|
|
13
17
|
if (!isValidDateObject(dt))
|
|
14
18
|
return date;
|
|
15
19
|
return `${DATE_YEAR_MONTHS[dt.getMonth()]} ${dt.getFullYear()}`;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transform a valid Date to [Quarter Year] date format.
|
|
3
4
|
* @param date String of a valid date, date object or millisencond number of the date
|
|
4
5
|
* @returns string of [Quarter Year] date format
|
|
5
6
|
*/
|
|
6
|
-
export declare function dateToQuarterYear(date: string | Date | number): string;
|
|
7
|
+
export declare function dateToQuarterYear(date: string | Date | number, settings?: IDateSettings): string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DATE_YEAR_QUARTERS } from "../constants/DATE_YEAR_QUARTERS";
|
|
2
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
3
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
2
4
|
import { isValidDateObject } from "../helpers/isValidDateObject";
|
|
3
5
|
import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
4
6
|
/**
|
|
@@ -6,10 +8,12 @@ import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
|
6
8
|
* @param date String of a valid date, date object or millisencond number of the date
|
|
7
9
|
* @returns string of [Quarter Year] date format
|
|
8
10
|
*/
|
|
9
|
-
export function dateToQuarterYear(date) {
|
|
11
|
+
export function dateToQuarterYear(date, settings) {
|
|
10
12
|
if (!isValidPotentialDate(date))
|
|
11
13
|
return date;
|
|
12
|
-
const
|
|
14
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
15
|
+
const timezonedDate = getDateByTimezone(date, defaultSettings.timezone);
|
|
16
|
+
const dt = new Date(timezonedDate.valueOf());
|
|
13
17
|
if (!isValidDateObject(dt))
|
|
14
18
|
return date;
|
|
15
19
|
const quarter = Math.ceil((dt.getMonth() + 1) / 3);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transform a Date to [W# Year] date format.
|
|
3
4
|
* @param date String, object or millisencond number of the date
|
|
4
5
|
* @returns string of [W# Year] date format
|
|
5
6
|
*/
|
|
6
|
-
export declare function dateToWeekYear(date: string | Date | number): string;
|
|
7
|
+
export declare function dateToWeekYear(date: string | Date | number, settings?: IDateSettings): string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
2
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
1
3
|
import { getWeek } from "../helpers/getWeek";
|
|
2
4
|
import { isValidDateObject } from "../helpers/isValidDateObject";
|
|
3
5
|
import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
@@ -6,10 +8,12 @@ import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
|
6
8
|
* @param date String, object or millisencond number of the date
|
|
7
9
|
* @returns string of [W# Year] date format
|
|
8
10
|
*/
|
|
9
|
-
export function dateToWeekYear(date) {
|
|
11
|
+
export function dateToWeekYear(date, settings) {
|
|
10
12
|
if (!isValidPotentialDate(date))
|
|
11
13
|
return date;
|
|
12
|
-
const
|
|
14
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
15
|
+
const timezonedDate = getDateByTimezone(date, defaultSettings.timezone);
|
|
16
|
+
const dt = new Date(timezonedDate.valueOf());
|
|
13
17
|
if (!isValidDateObject(dt))
|
|
14
18
|
return date;
|
|
15
19
|
const weekObj = getWeek(dt);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transform a Date to [Year] date format.
|
|
3
4
|
* @param {string | Date | number} date String, object or millisencond number of the date
|
|
4
5
|
* @returns string of [Year] date format
|
|
5
6
|
*/
|
|
6
|
-
export declare function dateToYear(date: string | Date | number): string;
|
|
7
|
+
export declare function dateToYear(date: string | Date | number, settings?: IDateSettings): string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
2
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
1
3
|
import { isValidDateObject } from "../helpers/isValidDateObject";
|
|
2
4
|
import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
3
5
|
/**
|
|
@@ -5,10 +7,12 @@ import { isValidPotentialDate } from "../helpers/isValidPotentialDate";
|
|
|
5
7
|
* @param {string | Date | number} date String, object or millisencond number of the date
|
|
6
8
|
* @returns string of [Year] date format
|
|
7
9
|
*/
|
|
8
|
-
export function dateToYear(date) {
|
|
10
|
+
export function dateToYear(date, settings) {
|
|
9
11
|
if (!isValidPotentialDate(date))
|
|
10
12
|
return date;
|
|
11
|
-
const
|
|
13
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
14
|
+
const timezonedDate = getDateByTimezone(date, defaultSettings.timezone);
|
|
15
|
+
const dt = new Date(timezonedDate.valueOf());
|
|
12
16
|
if (!isValidDateObject(dt))
|
|
13
17
|
return date;
|
|
14
18
|
return String(dt.getFullYear());
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transforms String time from a [H:m:s] format to Date object.
|
|
3
4
|
* @param monthYearDate String of [H:m:s] time
|
|
4
5
|
* @param time Flag to parse the object date to milliseconds.
|
|
5
6
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected time, the function will return the same value
|
|
6
7
|
*/
|
|
7
|
-
export declare function hmsToDate(hmsDate: string,
|
|
8
|
+
export declare function hmsToDate(hmsDate: string, settings?: IDateSettings): string | Date | number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
2
|
import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
3
3
|
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
5
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
4
6
|
import { validateDate } from "../helpers/validateDate";
|
|
5
7
|
/**
|
|
6
8
|
* Transforms String time from a [H:m:s] format to Date object.
|
|
@@ -8,13 +10,15 @@ import { validateDate } from "../helpers/validateDate";
|
|
|
8
10
|
* @param time Flag to parse the object date to milliseconds.
|
|
9
11
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected time, the function will return the same value
|
|
10
12
|
*/
|
|
11
|
-
export function hmsToDate(hmsDate,
|
|
13
|
+
export function hmsToDate(hmsDate, settings) {
|
|
12
14
|
if (isEmpty(hmsDate) ||
|
|
13
15
|
isTokenLabel(hmsDate) ||
|
|
14
16
|
typeof hmsDate !== "string" ||
|
|
15
17
|
!validateDate(hmsDate, DATE_FORMAT.DAY_TIME))
|
|
16
18
|
return hmsDate;
|
|
19
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
17
20
|
const [hour, minute, second] = hmsDate.split(":");
|
|
18
21
|
const start = new Date(0, 0, 0, +hour, +minute, +second);
|
|
19
|
-
|
|
22
|
+
const timezonedDate = getDateByTimezone(start, defaultSettings.timezone);
|
|
23
|
+
return defaultSettings.convertMiliseconds ? +timezonedDate : timezonedDate;
|
|
20
24
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transforms String Date from a [mm/dd/yyyy] format to Date object.
|
|
3
4
|
* @param monthYearDate String of [mm/dd/yyyy] date
|
|
4
5
|
* @param time Flag to parse the object date to milliseconds.
|
|
5
6
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value
|
|
6
7
|
*/
|
|
7
|
-
export declare function mdyDateToDate(date: string,
|
|
8
|
+
export declare function mdyDateToDate(date: string, settings?: IDateSettings): string | Date | number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
2
|
import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
3
3
|
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
5
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
4
6
|
import { validateDate } from "../helpers/validateDate";
|
|
5
7
|
/**
|
|
6
8
|
* Transforms String Date from a [mm/dd/yyyy] format to Date object.
|
|
@@ -8,13 +10,16 @@ import { validateDate } from "../helpers/validateDate";
|
|
|
8
10
|
* @param time Flag to parse the object date to milliseconds.
|
|
9
11
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value
|
|
10
12
|
*/
|
|
11
|
-
export function mdyDateToDate(date,
|
|
13
|
+
export function mdyDateToDate(date, settings) {
|
|
12
14
|
if (isEmpty(date) ||
|
|
13
15
|
isTokenLabel(date) ||
|
|
14
16
|
typeof date !== "string" ||
|
|
15
17
|
!validatingDate(date))
|
|
16
18
|
return date;
|
|
17
|
-
|
|
19
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
20
|
+
const dateObject = new Date(date);
|
|
21
|
+
const timezonedDate = getDateByTimezone(dateObject, defaultSettings.timezone);
|
|
22
|
+
return defaultSettings.convertMiliseconds ? +timezonedDate : timezonedDate;
|
|
18
23
|
}
|
|
19
24
|
function validatingDate(date) {
|
|
20
25
|
return (validateDate(date, DATE_FORMAT.DAY) ||
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transforms String Date from a [Month Year] format to Date object.
|
|
3
4
|
* @param monthYearDate String of [Month Year] date
|
|
4
5
|
* @param time Flag to parse the object date to milliseconds.
|
|
5
6
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value
|
|
6
7
|
*/
|
|
7
|
-
export declare function monthYearToDate(monthYearDate: string,
|
|
8
|
+
export declare function monthYearToDate(monthYearDate: string, settings?: IDateSettings): string | Date | number;
|
|
@@ -2,6 +2,8 @@ import { isEmpty } from "../../general/mix/isEmpty";
|
|
|
2
2
|
import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
3
3
|
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
4
|
import { DATE_YEAR_MONTHS } from "../constants/DATE_YEAR_MONTHS";
|
|
5
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
6
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
5
7
|
import { validateDate } from "../helpers/validateDate";
|
|
6
8
|
/**
|
|
7
9
|
* Transforms String Date from a [Month Year] format to Date object.
|
|
@@ -9,13 +11,15 @@ import { validateDate } from "../helpers/validateDate";
|
|
|
9
11
|
* @param time Flag to parse the object date to milliseconds.
|
|
10
12
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value
|
|
11
13
|
*/
|
|
12
|
-
export function monthYearToDate(monthYearDate,
|
|
14
|
+
export function monthYearToDate(monthYearDate, settings) {
|
|
13
15
|
if (isEmpty(monthYearDate) ||
|
|
14
16
|
isTokenLabel(monthYearDate) ||
|
|
15
17
|
typeof monthYearDate !== "string" ||
|
|
16
18
|
!validateDate(monthYearDate, DATE_FORMAT.MONTH))
|
|
17
19
|
return monthYearDate;
|
|
20
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
18
21
|
const [month, year] = monthYearDate.split(" ");
|
|
19
22
|
const start = new Date(+year, DATE_YEAR_MONTHS.indexOf(month), 1);
|
|
20
|
-
|
|
23
|
+
const timezonedDate = getDateByTimezone(start, defaultSettings.timezone);
|
|
24
|
+
return (defaultSettings === null || defaultSettings === void 0 ? void 0 : defaultSettings.convertMiliseconds) ? +timezonedDate : timezonedDate;
|
|
21
25
|
}
|
|
@@ -2,22 +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
|
|
13
|
-
|
|
14
|
-
if (typeof
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
newOffset =
|
|
14
|
+
if (typeof newOffset === "string" && newOffset === "browser")
|
|
15
|
+
newOffset = -1 * new Date().getTimezoneOffset();
|
|
16
|
+
if (typeof newOffset === "string" && isValidISOOffset(newOffset)) {
|
|
17
|
+
if (leadZeros)
|
|
18
|
+
return String(newOffset);
|
|
19
|
+
newOffset = ISOToNumericOffset(newOffset);
|
|
20
|
+
}
|
|
21
|
+
if (typeof newOffset !== "number" && isNaNV2(newOffset))
|
|
22
|
+
return leadZeros ? "+00:00" : "+0";
|
|
23
|
+
if (typeof newOffset === "string" && !isNaNV2(newOffset))
|
|
24
|
+
newOffset = +newOffset;
|
|
18
25
|
const sign = getSign(newOffset);
|
|
19
26
|
newOffset = Math.abs(newOffset);
|
|
20
|
-
const hours = padLeadingZeros(Math.floor(newOffset / 60),
|
|
27
|
+
const hours = padLeadingZeros(Math.floor(newOffset / 60), leadZeroNumber);
|
|
21
28
|
const minutes = padLeadingZeros(newOffset % 60, 2);
|
|
22
29
|
return `${sign}${hours}:${minutes}`;
|
|
23
30
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transforms String Date from a [Quarter Year] format to Date object.
|
|
3
4
|
* @param quarterYearDate String of [Quarter Year] date
|
|
4
5
|
* @param time Flag to parse the object date to milliseconds.
|
|
5
6
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
|
|
6
7
|
*/
|
|
7
|
-
export declare function quarterYearToDate(quarterYearDate: string,
|
|
8
|
+
export declare function quarterYearToDate(quarterYearDate: string, settings?: IDateSettings): string | Date | number;
|
|
@@ -2,6 +2,8 @@ import { isEmpty } from "../../general/mix/isEmpty";
|
|
|
2
2
|
import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
3
3
|
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
4
|
import { DATE_YEAR_QUARTERS_RANGE } from "../constants/DATE_YEAR_QUARTERS_RANGE";
|
|
5
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
6
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
5
7
|
import { validateDate } from "../helpers/validateDate";
|
|
6
8
|
/**
|
|
7
9
|
* Transforms String Date from a [Quarter Year] format to Date object.
|
|
@@ -9,13 +11,15 @@ import { validateDate } from "../helpers/validateDate";
|
|
|
9
11
|
* @param time Flag to parse the object date to milliseconds.
|
|
10
12
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
|
|
11
13
|
*/
|
|
12
|
-
export function quarterYearToDate(quarterYearDate,
|
|
14
|
+
export function quarterYearToDate(quarterYearDate, settings) {
|
|
13
15
|
if (isEmpty(quarterYearDate) ||
|
|
14
16
|
isTokenLabel(quarterYearDate) ||
|
|
15
17
|
typeof quarterYearDate !== "string" ||
|
|
16
18
|
!validateDate(quarterYearDate, DATE_FORMAT.QUARTER))
|
|
17
19
|
return quarterYearDate;
|
|
20
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
18
21
|
const [quarter, year] = quarterYearDate.split(" ");
|
|
19
22
|
const start = new Date(+year, DATE_YEAR_QUARTERS_RANGE[quarter].initial, 1);
|
|
20
|
-
|
|
23
|
+
const timezonedDate = getDateByTimezone(start, defaultSettings.timezone);
|
|
24
|
+
return (defaultSettings === null || defaultSettings === void 0 ? void 0 : defaultSettings.convertMiliseconds) ? +timezonedDate : timezonedDate;
|
|
21
25
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transforms String Date from a [Week Year] format to Date object.
|
|
3
4
|
* @param date String of [Week Year] date
|
|
4
5
|
* @param time Flag to parse the object date to milliseconds.
|
|
5
6
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
|
|
6
7
|
*/
|
|
7
|
-
export declare function weekYearToDate(weekYear: string,
|
|
8
|
+
export declare function weekYearToDate(weekYear: string, settings?: IDateSettings): string | Date | number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
2
|
import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
3
3
|
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
5
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
4
6
|
import { getWeek } from "../helpers/getWeek";
|
|
5
7
|
import { validateDate } from "../helpers/validateDate";
|
|
6
8
|
/**
|
|
@@ -9,12 +11,13 @@ import { validateDate } from "../helpers/validateDate";
|
|
|
9
11
|
* @param time Flag to parse the object date to milliseconds.
|
|
10
12
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
|
|
11
13
|
*/
|
|
12
|
-
export function weekYearToDate(weekYear,
|
|
14
|
+
export function weekYearToDate(weekYear, settings) {
|
|
13
15
|
if (isEmpty(weekYear) ||
|
|
14
16
|
isTokenLabel(weekYear) ||
|
|
15
17
|
typeof weekYear !== "string" ||
|
|
16
18
|
!validateDate(weekYear, DATE_FORMAT.WEEK))
|
|
17
19
|
return weekYear;
|
|
20
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
18
21
|
const [week, year] = weekYear.split(" ");
|
|
19
22
|
const weekNumber = Number(week.substring(1));
|
|
20
23
|
const dateObj = new Date(+year, 1, 1);
|
|
@@ -24,5 +27,6 @@ export function weekYearToDate(weekYear, time = false) {
|
|
|
24
27
|
const weeksInTheFuture = weekNumber - weekNoToday;
|
|
25
28
|
dateObj.setDate(dateObj.getDate() + 7 * weeksInTheFuture);
|
|
26
29
|
const date = new Date(`${dateObj.getMonth() + 1}/${dateObj.getDate()}/${dateObj.getFullYear()}`);
|
|
27
|
-
|
|
30
|
+
const timezonedDate = getDateByTimezone(date, defaultSettings.timezone);
|
|
31
|
+
return (defaultSettings === null || defaultSettings === void 0 ? void 0 : defaultSettings.convertMiliseconds) ? +timezonedDate : timezonedDate;
|
|
28
32
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
1
2
|
/**
|
|
2
3
|
* Transforms String Date from a [Year] format to Date object.
|
|
3
4
|
* @param yearDate String of [Year] date
|
|
4
5
|
* @param time Flag to parse the object date to milliseconds.
|
|
5
6
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
|
|
6
7
|
*/
|
|
7
|
-
export declare function yearToDate(yearDate: string,
|
|
8
|
+
export declare function yearToDate(yearDate: string, settings?: IDateSettings): string | Date | number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
2
|
import { isTokenLabel } from "../../tokens/isTokenLabel";
|
|
3
3
|
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
4
|
+
import { getDateByTimezone } from "../helpers/getDateByTimezone";
|
|
5
|
+
import { getDefaultDateSettings } from "../helpers/getDefaultDateSettings";
|
|
4
6
|
import { validateDate } from "../helpers/validateDate";
|
|
5
7
|
/**
|
|
6
8
|
* Transforms String Date from a [Year] format to Date object.
|
|
@@ -8,12 +10,14 @@ import { validateDate } from "../helpers/validateDate";
|
|
|
8
10
|
* @param time Flag to parse the object date to milliseconds.
|
|
9
11
|
* @returns The date object or the date in milliseconds. If the argument is an unexpected date, the function will return the same value.
|
|
10
12
|
*/
|
|
11
|
-
export function yearToDate(yearDate,
|
|
13
|
+
export function yearToDate(yearDate, settings) {
|
|
12
14
|
if (isEmpty(yearDate) ||
|
|
13
15
|
isTokenLabel(yearDate) ||
|
|
14
16
|
typeof yearDate !== "string" ||
|
|
15
17
|
!validateDate(yearDate, DATE_FORMAT.YEAR))
|
|
16
18
|
return yearDate;
|
|
19
|
+
const defaultSettings = getDefaultDateSettings(settings);
|
|
17
20
|
const start = new Date(+yearDate, 0, 1);
|
|
18
|
-
|
|
21
|
+
const timezonedDate = getDateByTimezone(start, defaultSettings.timezone);
|
|
22
|
+
return (defaultSettings === null || defaultSettings === void 0 ? void 0 : defaultSettings.convertMiliseconds) ? +timezonedDate : timezonedDate;
|
|
19
23
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IDateFormat } from "../interfaces/IDateFormat";
|
|
2
|
+
import { IDateSettings } from "../interfaces/IDateSettings";
|
|
2
3
|
/**
|
|
3
4
|
* Gets a Date Object instance by a Date format
|
|
4
5
|
* @param date String with a formatted date
|
|
@@ -6,4 +7,4 @@ import { IDateFormat } from "../interfaces/IDateFormat";
|
|
|
6
7
|
* @param time flag to convert the formatted date to miliseconds
|
|
7
8
|
* @returns a Date object, milisecond time or the same value if date format does not match.
|
|
8
9
|
*/
|
|
9
|
-
export declare function getDateByDateFormat(date: string, format: IDateFormat,
|
|
10
|
+
export declare function getDateByDateFormat(date: string, format: IDateFormat, settings?: IDateSettings): string | Date | number;
|