@qrvey/utils 1.11.0-1 → 1.11.0-1-features-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/dist/cjs/columns/helpers/index.d.ts +1 -0
- package/dist/cjs/columns/helpers/index.js +1 -0
- package/dist/cjs/columns/helpers/isDurationColumn.d.ts +7 -0
- package/dist/cjs/columns/helpers/isDurationColumn.js +18 -0
- package/dist/cjs/columns/interfaces/IColumnPropertyType.d.ts +2 -1
- package/dist/cjs/dates/helpers/getTimezoneObject.js +1 -1
- package/dist/cjs/filters/adapters/FDToFlatUI.js +2 -1
- package/dist/cjs/filters/adapters/UIToOldLogic.js +1 -0
- package/dist/cjs/filters/adapters/logicToFlatUI.js +4 -4
- package/dist/cjs/filters/constants/settings/FILTER_SETTINGS_DEFAULT.js +2 -0
- package/dist/cjs/filters/helpers/backend/getBackendValues.js +3 -1
- package/dist/cjs/filters/helpers/common/adaptTimeUnitValuesFromFilters.d.ts +11 -0
- package/dist/cjs/filters/helpers/common/adaptTimeUnitValuesFromFilters.js +29 -0
- package/dist/cjs/filters/helpers/common/index.d.ts +1 -0
- package/dist/cjs/filters/helpers/common/index.js +1 -0
- package/dist/cjs/filters/helpers/common/resolveDatasetConditions.js +5 -0
- package/dist/cjs/filters/helpers/common/resolveFilterConditions.js +5 -0
- package/dist/cjs/filters/helpers/common/resolveScopeConditions.js +5 -0
- package/dist/cjs/filters/interfaces/OLD_IFilterDetail.d.ts +4 -0
- package/dist/cjs/filters/interfaces/builder/IFilterBuilderSettings.d.ts +5 -0
- package/dist/cjs/filters/interfaces/common/IFSParamsToGetFilter.d.ts +2 -0
- package/dist/cjs/filters/interfaces/common/IFSParamsToGetFilterDisplayeds.d.ts +9 -0
- package/dist/cjs/filters/interfaces/common/IFSParamsToGetFilterDisplayeds.js +2 -0
- package/dist/cjs/filters/interfaces/common/index.d.ts +1 -0
- package/dist/cjs/filters/interfaces/common/index.js +1 -0
- package/dist/cjs/filters/interfaces/settings/IFSettingsFilterBuilder.d.ts +1 -0
- package/dist/cjs/filters/interfaces/settings/IFSettingsFilterPanel.d.ts +1 -0
- package/dist/cjs/format/definition.d.ts +1 -0
- package/dist/cjs/format/definition.js +2 -1
- package/dist/cjs/format/duration/convertTimeUnit.d.ts +15 -0
- package/dist/cjs/format/duration/convertTimeUnit.js +34 -0
- package/dist/cjs/format/duration/index.d.ts +1 -0
- package/dist/cjs/format/duration/index.js +1 -0
- package/dist/cjs/globalization/interfaces/common/I18nTimeUnitProperties.d.ts +10 -0
- package/dist/cjs/globalization/interfaces/common/I18nTimeUnitProperties.js +2 -0
- package/dist/cjs/globalization/interfaces/common/II18nCommon.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/common/index.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/common/index.js +1 -0
- package/dist/cjs/globalization/interfaces/tabular_view/II18nTabularView.d.ts +1 -0
- package/dist/cjs/globalization/labels/common/I18N_COMMON.js +2 -0
- package/dist/cjs/globalization/labels/common/I18N_TIME_UNITS.d.ts +2 -0
- package/dist/cjs/globalization/labels/common/I18N_TIME_UNITS.js +14 -0
- package/dist/cjs/globalization/labels/tabular_view/I18N_TABULAR_VIEW.js +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/qrvey/helpers/getPropertyLabel.d.ts +7 -0
- package/dist/cjs/qrvey/helpers/getPropertyLabel.js +14 -3
- package/dist/cjs/time/adapters/adaptTimeUnitNumbers.d.ts +9 -0
- package/dist/cjs/time/adapters/adaptTimeUnitNumbers.js +204 -0
- package/dist/cjs/time/adapters/daysToHours.d.ts +6 -0
- package/dist/cjs/time/adapters/daysToHours.js +22 -0
- package/dist/cjs/time/adapters/daysToMinutes.d.ts +6 -0
- package/dist/cjs/time/adapters/daysToMinutes.js +22 -0
- package/dist/cjs/time/adapters/daysToMonths.d.ts +6 -0
- package/dist/cjs/time/adapters/daysToMonths.js +22 -0
- package/dist/cjs/time/adapters/daysToSeconds.d.ts +6 -0
- package/dist/cjs/time/adapters/daysToSeconds.js +22 -0
- package/dist/cjs/time/adapters/daysToYears.d.ts +6 -0
- package/dist/cjs/time/adapters/daysToYears.js +22 -0
- package/dist/cjs/time/adapters/hoursToDays.d.ts +6 -0
- package/dist/cjs/time/adapters/hoursToDays.js +22 -0
- package/dist/cjs/time/adapters/hoursToMinutes.d.ts +6 -0
- package/dist/cjs/time/adapters/hoursToMinutes.js +22 -0
- package/dist/cjs/time/adapters/hoursToMonths.d.ts +6 -0
- package/dist/cjs/time/adapters/hoursToMonths.js +22 -0
- package/dist/cjs/time/adapters/hoursToSeconds.d.ts +6 -0
- package/dist/cjs/time/adapters/hoursToSeconds.js +22 -0
- package/dist/cjs/time/adapters/hoursToYears.d.ts +6 -0
- package/dist/cjs/time/adapters/hoursToYears.js +22 -0
- package/dist/cjs/time/adapters/index.d.ts +31 -0
- package/dist/cjs/time/adapters/index.js +47 -0
- package/dist/cjs/time/adapters/minutesToDays.d.ts +6 -0
- package/dist/cjs/time/adapters/minutesToDays.js +22 -0
- package/dist/cjs/time/adapters/minutesToHours.d.ts +6 -0
- package/dist/cjs/time/adapters/minutesToHours.js +22 -0
- package/dist/cjs/time/adapters/minutesToMonths.d.ts +6 -0
- package/dist/cjs/time/adapters/minutesToMonths.js +22 -0
- package/dist/cjs/time/adapters/minutesToSeconds.d.ts +6 -0
- package/dist/cjs/time/adapters/minutesToSeconds.js +22 -0
- package/dist/cjs/time/adapters/minutesToYears.d.ts +6 -0
- package/dist/cjs/time/adapters/minutesToYears.js +22 -0
- package/dist/cjs/time/adapters/monthsToDays.d.ts +6 -0
- package/dist/cjs/time/adapters/monthsToDays.js +22 -0
- package/dist/cjs/time/adapters/monthsToHours.d.ts +6 -0
- package/dist/cjs/time/adapters/monthsToHours.js +22 -0
- package/dist/cjs/time/adapters/monthsToMinutes.d.ts +6 -0
- package/dist/cjs/time/adapters/monthsToMinutes.js +22 -0
- package/dist/cjs/time/adapters/monthsToSeconds.d.ts +6 -0
- package/dist/cjs/time/adapters/monthsToSeconds.js +22 -0
- package/dist/cjs/time/adapters/monthsToYears.d.ts +6 -0
- package/dist/cjs/time/adapters/monthsToYears.js +22 -0
- package/dist/cjs/time/adapters/secondsToDays.d.ts +6 -0
- package/dist/cjs/time/adapters/secondsToDays.js +22 -0
- package/dist/cjs/time/adapters/secondsToHours.d.ts +6 -0
- package/dist/cjs/time/adapters/secondsToHours.js +22 -0
- package/dist/cjs/time/adapters/secondsToMinutes.d.ts +6 -0
- package/dist/cjs/time/adapters/secondsToMinutes.js +22 -0
- package/dist/cjs/time/adapters/secondsToMonths.d.ts +6 -0
- package/dist/cjs/time/adapters/secondsToMonths.js +22 -0
- package/dist/cjs/time/adapters/secondsToYears.d.ts +6 -0
- package/dist/cjs/time/adapters/secondsToYears.js +22 -0
- package/dist/cjs/time/adapters/yearsToDays.d.ts +6 -0
- package/dist/cjs/time/adapters/yearsToDays.js +22 -0
- package/dist/cjs/time/adapters/yearsToHours.d.ts +6 -0
- package/dist/cjs/time/adapters/yearsToHours.js +22 -0
- package/dist/cjs/time/adapters/yearsToMinutes.d.ts +6 -0
- package/dist/cjs/time/adapters/yearsToMinutes.js +22 -0
- package/dist/cjs/time/adapters/yearsToMonths.d.ts +6 -0
- package/dist/cjs/time/adapters/yearsToMonths.js +22 -0
- package/dist/cjs/time/adapters/yearsToSeconds.d.ts +6 -0
- package/dist/cjs/time/adapters/yearsToSeconds.js +22 -0
- package/dist/cjs/time/constants/TIME_UNIT_INFO.d.ts +5 -0
- package/dist/cjs/time/constants/TIME_UNIT_INFO.js +55 -0
- package/dist/cjs/time/constants/TIME_UNIT_INFO_LIST.d.ts +2 -0
- package/dist/cjs/time/constants/TIME_UNIT_INFO_LIST.js +13 -0
- package/dist/cjs/time/constants/TIME_UNIT_PROPERTY.d.ts +8 -0
- package/dist/cjs/time/constants/TIME_UNIT_PROPERTY.js +12 -0
- package/dist/cjs/time/constants/TIME_UNIT_PROPERTY_LABEL.d.ts +8 -0
- package/dist/cjs/time/constants/TIME_UNIT_PROPERTY_LABEL.js +12 -0
- package/dist/cjs/time/constants/index.d.ts +4 -0
- package/dist/cjs/time/constants/index.js +20 -0
- package/dist/cjs/time/index.d.ts +3 -0
- package/dist/cjs/time/index.js +19 -0
- package/dist/cjs/time/interfaces/ITimeUnitProperty.d.ts +2 -0
- package/dist/cjs/time/interfaces/ITimeUnitProperty.js +2 -0
- package/dist/cjs/time/interfaces/ITimeUnitPropertyInfo.d.ts +5 -0
- package/dist/cjs/time/interfaces/ITimeUnitPropertyInfo.js +2 -0
- package/dist/cjs/time/interfaces/index.d.ts +2 -0
- package/dist/cjs/time/interfaces/index.js +18 -0
- package/dist/columns/helpers/index.d.ts +1 -0
- package/dist/columns/helpers/index.js +1 -0
- package/dist/columns/helpers/isDurationColumn.d.ts +7 -0
- package/dist/columns/helpers/isDurationColumn.js +14 -0
- package/dist/columns/interfaces/IColumnPropertyType.d.ts +2 -1
- package/dist/dates/helpers/getTimezoneObject.js +1 -1
- package/dist/filters/adapters/FDToFlatUI.js +2 -1
- package/dist/filters/adapters/UIToOldLogic.js +1 -0
- package/dist/filters/adapters/logicToFlatUI.js +4 -4
- package/dist/filters/constants/settings/FILTER_SETTINGS_DEFAULT.js +2 -0
- package/dist/filters/helpers/backend/getBackendValues.js +3 -1
- package/dist/filters/helpers/common/adaptTimeUnitValuesFromFilters.d.ts +11 -0
- package/dist/filters/helpers/common/adaptTimeUnitValuesFromFilters.js +25 -0
- package/dist/filters/helpers/common/index.d.ts +1 -0
- package/dist/filters/helpers/common/index.js +1 -0
- package/dist/filters/helpers/common/resolveDatasetConditions.js +5 -0
- package/dist/filters/helpers/common/resolveFilterConditions.js +5 -0
- package/dist/filters/helpers/common/resolveScopeConditions.js +5 -0
- package/dist/filters/interfaces/OLD_IFilterDetail.d.ts +4 -0
- package/dist/filters/interfaces/builder/IFilterBuilderSettings.d.ts +5 -0
- package/dist/filters/interfaces/common/IFSParamsToGetFilter.d.ts +2 -0
- package/dist/filters/interfaces/common/IFSParamsToGetFilterDisplayeds.d.ts +9 -0
- package/dist/filters/interfaces/common/IFSParamsToGetFilterDisplayeds.js +1 -0
- package/dist/filters/interfaces/common/index.d.ts +1 -0
- package/dist/filters/interfaces/common/index.js +1 -0
- package/dist/filters/interfaces/settings/IFSettingsFilterBuilder.d.ts +1 -0
- package/dist/filters/interfaces/settings/IFSettingsFilterPanel.d.ts +1 -0
- package/dist/format/definition.d.ts +1 -0
- package/dist/format/definition.js +1 -0
- package/dist/format/duration/convertTimeUnit.d.ts +15 -0
- package/dist/format/duration/convertTimeUnit.js +27 -0
- package/dist/format/duration/index.d.ts +1 -0
- package/dist/format/duration/index.js +1 -0
- package/dist/globalization/interfaces/common/I18nTimeUnitProperties.d.ts +10 -0
- package/dist/globalization/interfaces/common/I18nTimeUnitProperties.js +1 -0
- package/dist/globalization/interfaces/common/II18nCommon.d.ts +2 -0
- package/dist/globalization/interfaces/common/index.d.ts +1 -0
- package/dist/globalization/interfaces/common/index.js +1 -0
- package/dist/globalization/interfaces/tabular_view/II18nTabularView.d.ts +1 -0
- package/dist/globalization/labels/common/I18N_COMMON.js +2 -0
- package/dist/globalization/labels/common/I18N_TIME_UNITS.d.ts +2 -0
- package/dist/globalization/labels/common/I18N_TIME_UNITS.js +11 -0
- package/dist/globalization/labels/tabular_view/I18N_TABULAR_VIEW.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/qrvey/helpers/getPropertyLabel.d.ts +7 -0
- package/dist/qrvey/helpers/getPropertyLabel.js +14 -3
- package/dist/time/adapters/adaptTimeUnitNumbers.d.ts +9 -0
- package/dist/time/adapters/adaptTimeUnitNumbers.js +200 -0
- package/dist/time/adapters/daysToHours.d.ts +6 -0
- package/dist/time/adapters/daysToHours.js +15 -0
- package/dist/time/adapters/daysToMinutes.d.ts +6 -0
- package/dist/time/adapters/daysToMinutes.js +15 -0
- package/dist/time/adapters/daysToMonths.d.ts +6 -0
- package/dist/time/adapters/daysToMonths.js +15 -0
- package/dist/time/adapters/daysToSeconds.d.ts +6 -0
- package/dist/time/adapters/daysToSeconds.js +15 -0
- package/dist/time/adapters/daysToYears.d.ts +6 -0
- package/dist/time/adapters/daysToYears.js +15 -0
- package/dist/time/adapters/hoursToDays.d.ts +6 -0
- package/dist/time/adapters/hoursToDays.js +15 -0
- package/dist/time/adapters/hoursToMinutes.d.ts +6 -0
- package/dist/time/adapters/hoursToMinutes.js +15 -0
- package/dist/time/adapters/hoursToMonths.d.ts +6 -0
- package/dist/time/adapters/hoursToMonths.js +15 -0
- package/dist/time/adapters/hoursToSeconds.d.ts +6 -0
- package/dist/time/adapters/hoursToSeconds.js +15 -0
- package/dist/time/adapters/hoursToYears.d.ts +6 -0
- package/dist/time/adapters/hoursToYears.js +15 -0
- package/dist/time/adapters/index.d.ts +31 -0
- package/dist/time/adapters/index.js +31 -0
- package/dist/time/adapters/minutesToDays.d.ts +6 -0
- package/dist/time/adapters/minutesToDays.js +15 -0
- package/dist/time/adapters/minutesToHours.d.ts +6 -0
- package/dist/time/adapters/minutesToHours.js +15 -0
- package/dist/time/adapters/minutesToMonths.d.ts +6 -0
- package/dist/time/adapters/minutesToMonths.js +15 -0
- package/dist/time/adapters/minutesToSeconds.d.ts +6 -0
- package/dist/time/adapters/minutesToSeconds.js +15 -0
- package/dist/time/adapters/minutesToYears.d.ts +6 -0
- package/dist/time/adapters/minutesToYears.js +15 -0
- package/dist/time/adapters/monthsToDays.d.ts +6 -0
- package/dist/time/adapters/monthsToDays.js +15 -0
- package/dist/time/adapters/monthsToHours.d.ts +6 -0
- package/dist/time/adapters/monthsToHours.js +15 -0
- package/dist/time/adapters/monthsToMinutes.d.ts +6 -0
- package/dist/time/adapters/monthsToMinutes.js +15 -0
- package/dist/time/adapters/monthsToSeconds.d.ts +6 -0
- package/dist/time/adapters/monthsToSeconds.js +15 -0
- package/dist/time/adapters/monthsToYears.d.ts +6 -0
- package/dist/time/adapters/monthsToYears.js +15 -0
- package/dist/time/adapters/secondsToDays.d.ts +6 -0
- package/dist/time/adapters/secondsToDays.js +15 -0
- package/dist/time/adapters/secondsToHours.d.ts +6 -0
- package/dist/time/adapters/secondsToHours.js +15 -0
- package/dist/time/adapters/secondsToMinutes.d.ts +6 -0
- package/dist/time/adapters/secondsToMinutes.js +15 -0
- package/dist/time/adapters/secondsToMonths.d.ts +6 -0
- package/dist/time/adapters/secondsToMonths.js +15 -0
- package/dist/time/adapters/secondsToYears.d.ts +6 -0
- package/dist/time/adapters/secondsToYears.js +15 -0
- package/dist/time/adapters/yearsToDays.d.ts +6 -0
- package/dist/time/adapters/yearsToDays.js +15 -0
- package/dist/time/adapters/yearsToHours.d.ts +6 -0
- package/dist/time/adapters/yearsToHours.js +15 -0
- package/dist/time/adapters/yearsToMinutes.d.ts +6 -0
- package/dist/time/adapters/yearsToMinutes.js +15 -0
- package/dist/time/adapters/yearsToMonths.d.ts +6 -0
- package/dist/time/adapters/yearsToMonths.js +15 -0
- package/dist/time/adapters/yearsToSeconds.d.ts +6 -0
- package/dist/time/adapters/yearsToSeconds.js +15 -0
- package/dist/time/constants/TIME_UNIT_INFO.d.ts +5 -0
- package/dist/time/constants/TIME_UNIT_INFO.js +52 -0
- package/dist/time/constants/TIME_UNIT_INFO_LIST.d.ts +2 -0
- package/dist/time/constants/TIME_UNIT_INFO_LIST.js +10 -0
- package/dist/time/constants/TIME_UNIT_PROPERTY.d.ts +8 -0
- package/dist/time/constants/TIME_UNIT_PROPERTY.js +9 -0
- package/dist/time/constants/TIME_UNIT_PROPERTY_LABEL.d.ts +8 -0
- package/dist/time/constants/TIME_UNIT_PROPERTY_LABEL.js +9 -0
- package/dist/time/constants/index.d.ts +4 -0
- package/dist/time/constants/index.js +4 -0
- package/dist/time/index.d.ts +3 -0
- package/dist/time/index.js +3 -0
- package/dist/time/interfaces/ITimeUnitProperty.d.ts +2 -0
- package/dist/time/interfaces/ITimeUnitProperty.js +1 -0
- package/dist/time/interfaces/ITimeUnitPropertyInfo.d.ts +5 -0
- package/dist/time/interfaces/ITimeUnitPropertyInfo.js +1 -0
- package/dist/time/interfaces/index.d.ts +2 -0
- package/dist/time/interfaces/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TIME_UNIT_PROPERTY_LABEL } from "../../../time/constants/TIME_UNIT_PROPERTY_LABEL";
|
|
2
|
+
export const I18N_TIME_UNITS = {
|
|
3
|
+
day: TIME_UNIT_PROPERTY_LABEL.DAY,
|
|
4
|
+
hour: TIME_UNIT_PROPERTY_LABEL.HOUR,
|
|
5
|
+
minute: TIME_UNIT_PROPERTY_LABEL.MINUTE,
|
|
6
|
+
month: TIME_UNIT_PROPERTY_LABEL.MONTH,
|
|
7
|
+
second: TIME_UNIT_PROPERTY_LABEL.SECOND,
|
|
8
|
+
year: TIME_UNIT_PROPERTY_LABEL.YEAR,
|
|
9
|
+
title: "Time Unit",
|
|
10
|
+
placeholder: "Select Time Unit",
|
|
11
|
+
};
|
|
@@ -14,6 +14,7 @@ export const I18N_TABULAR_VIEW = {
|
|
|
14
14
|
edit_modal_edit_option: "Update",
|
|
15
15
|
edit_modal_cancel_option: "Cancel",
|
|
16
16
|
filter_access_point: "Filter",
|
|
17
|
+
no_columns_selected_message: "No columns selected",
|
|
17
18
|
no_records_found_message: "No Records Found",
|
|
18
19
|
select_columns_all_option: "All",
|
|
19
20
|
select_columns_date_option: "Date",
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
|
|
2
2
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
3
3
|
import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the label of a property by the column
|
|
6
|
+
* @param {IColumn} column the column object
|
|
7
|
+
* @param {IColumnPropertyType} property the column property
|
|
8
|
+
* @param translate function to apply the i18n translation
|
|
9
|
+
* @returns the label
|
|
10
|
+
*/
|
|
4
11
|
export declare function getPropertyLabel(column: IColumn, property: IColumnPropertyType, translate?: II18nServiceTranslate): string;
|
|
@@ -2,11 +2,22 @@ import { COLUMN_PROPERTY_INFO } from "../../columns/constants/COLUMN_PROPERTY_IN
|
|
|
2
2
|
import { isDateColumn } from "../../columns/helpers/isDateColumn";
|
|
3
3
|
import { COLUMN } from "../../columns/constants/COLUMN";
|
|
4
4
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
5
|
+
import { isDurationColumn } from "../../columns/helpers/isDurationColumn";
|
|
6
|
+
import { TIME_UNIT_INFO_LIST } from "../../time/constants/TIME_UNIT_INFO_LIST";
|
|
7
|
+
/**
|
|
8
|
+
* Gets the label of a property by the column
|
|
9
|
+
* @param {IColumn} column the column object
|
|
10
|
+
* @param {IColumnPropertyType} property the column property
|
|
11
|
+
* @param translate function to apply the i18n translation
|
|
12
|
+
* @returns the label
|
|
13
|
+
*/
|
|
5
14
|
export function getPropertyLabel(column, property, translate) {
|
|
6
15
|
let propertyLabel;
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
16
|
+
let columnProperties = COLUMN_PROPERTY_INFO[isDateColumn(column) ? COLUMN.DATE : column.type];
|
|
17
|
+
if (isEmpty(columnProperties) && isDurationColumn(column))
|
|
18
|
+
columnProperties = TIME_UNIT_INFO_LIST;
|
|
19
|
+
if (!isEmpty(columnProperties)) {
|
|
20
|
+
const propertyObject = columnProperties.find((pValue) => pValue.value === property);
|
|
10
21
|
if (!isEmpty(propertyObject))
|
|
11
22
|
propertyLabel = !isEmpty(translate)
|
|
12
23
|
? translate(propertyObject.i18nLabelPath)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ITimeUnitProperty } from "../interfaces/ITimeUnitProperty";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a number from a time unit to another
|
|
4
|
+
* @param {ITimeUnitProperty} from a time unit
|
|
5
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
6
|
+
* @param {number} number the number to convert
|
|
7
|
+
* @returns the converted number
|
|
8
|
+
*/
|
|
9
|
+
export declare function adaptTimeUnitNumbers(from: ITimeUnitProperty, to: ITimeUnitProperty, number: number): number;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
3
|
+
import { TIME_UNIT_PROPERTY } from "../constants/TIME_UNIT_PROPERTY";
|
|
4
|
+
import { daysToHours } from "./daysToHours";
|
|
5
|
+
import { daysToMinutes } from "./daysToMinutes";
|
|
6
|
+
import { daysToMonths } from "./daysToMonths";
|
|
7
|
+
import { daysToSeconds } from "./daysToSeconds";
|
|
8
|
+
import { daysToYears } from "./daysToYears";
|
|
9
|
+
import { hoursToDays } from "./hoursToDays";
|
|
10
|
+
import { hoursToMinutes } from "./hoursToMinutes";
|
|
11
|
+
import { hoursToMonths } from "./hoursToMonths";
|
|
12
|
+
import { hoursToSeconds } from "./hoursToSeconds";
|
|
13
|
+
import { hoursToYears } from "./hoursToYears";
|
|
14
|
+
import { minutesToDays } from "./minutesToDays";
|
|
15
|
+
import { minutesToHours } from "./minutesToHours";
|
|
16
|
+
import { minutesToMonths } from "./minutesToMonths";
|
|
17
|
+
import { minutesToSeconds } from "./minutesToSeconds";
|
|
18
|
+
import { minutesToYears } from "./minutesToYears";
|
|
19
|
+
import { monthsToDays } from "./monthsToDays";
|
|
20
|
+
import { monthsToHours } from "./monthsToHours";
|
|
21
|
+
import { monthsToMinutes } from "./monthsToMinutes";
|
|
22
|
+
import { monthsToSeconds } from "./monthsToSeconds";
|
|
23
|
+
import { monthsToYears } from "./monthsToYears";
|
|
24
|
+
import { secondsToDays } from "./secondsToDays";
|
|
25
|
+
import { secondsToHours } from "./secondsToHours";
|
|
26
|
+
import { secondsToMinutes } from "./secondsToMinutes";
|
|
27
|
+
import { secondsToMonths } from "./secondsToMonths";
|
|
28
|
+
import { secondsToYears } from "./secondsToYears";
|
|
29
|
+
import { yearsToDays } from "./yearsToDays";
|
|
30
|
+
import { yearsToHours } from "./yearsToHours";
|
|
31
|
+
import { yearsToMinutes } from "./yearsToMinutes";
|
|
32
|
+
import { yearsToMonths } from "./yearsToMonths";
|
|
33
|
+
import { yearsToSeconds } from "./yearsToSeconds";
|
|
34
|
+
/**
|
|
35
|
+
* Converts a number from a time unit to another
|
|
36
|
+
* @param {ITimeUnitProperty} from a time unit
|
|
37
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
38
|
+
* @param {number} number the number to convert
|
|
39
|
+
* @returns the converted number
|
|
40
|
+
*/
|
|
41
|
+
export function adaptTimeUnitNumbers(from, to, number) {
|
|
42
|
+
if (validateArgumentts(from, to, number))
|
|
43
|
+
return 0;
|
|
44
|
+
switch (from) {
|
|
45
|
+
case TIME_UNIT_PROPERTY.DAY:
|
|
46
|
+
return dayConversion(to, number);
|
|
47
|
+
case TIME_UNIT_PROPERTY.HOUR:
|
|
48
|
+
return hourConversion(to, number);
|
|
49
|
+
case TIME_UNIT_PROPERTY.MINUTE:
|
|
50
|
+
return minuteConversion(to, number);
|
|
51
|
+
case TIME_UNIT_PROPERTY.MONTH:
|
|
52
|
+
return monthConversion(to, number);
|
|
53
|
+
case TIME_UNIT_PROPERTY.YEAR:
|
|
54
|
+
return yearConversion(to, number);
|
|
55
|
+
default:
|
|
56
|
+
return secondConversion(to, number);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Converts day number to another time unit
|
|
61
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
62
|
+
* @param {number} number the number to convert
|
|
63
|
+
* @returns the converted number
|
|
64
|
+
*/
|
|
65
|
+
function dayConversion(to, number) {
|
|
66
|
+
switch (to) {
|
|
67
|
+
case TIME_UNIT_PROPERTY.HOUR:
|
|
68
|
+
return daysToHours(number);
|
|
69
|
+
case TIME_UNIT_PROPERTY.MINUTE:
|
|
70
|
+
return daysToMinutes(number);
|
|
71
|
+
case TIME_UNIT_PROPERTY.MONTH:
|
|
72
|
+
return daysToMonths(number);
|
|
73
|
+
case TIME_UNIT_PROPERTY.SECOND:
|
|
74
|
+
return daysToSeconds(number);
|
|
75
|
+
case TIME_UNIT_PROPERTY.YEAR:
|
|
76
|
+
return daysToYears(number);
|
|
77
|
+
default:
|
|
78
|
+
return number || 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Converts hour number to another time unit
|
|
83
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
84
|
+
* @param {number} number the number to convert
|
|
85
|
+
* @returns the converted number
|
|
86
|
+
*/
|
|
87
|
+
function hourConversion(to, number) {
|
|
88
|
+
switch (to) {
|
|
89
|
+
case TIME_UNIT_PROPERTY.DAY:
|
|
90
|
+
return hoursToDays(number);
|
|
91
|
+
case TIME_UNIT_PROPERTY.MINUTE:
|
|
92
|
+
return hoursToMinutes(number);
|
|
93
|
+
case TIME_UNIT_PROPERTY.MONTH:
|
|
94
|
+
return hoursToMonths(number);
|
|
95
|
+
case TIME_UNIT_PROPERTY.SECOND:
|
|
96
|
+
return hoursToSeconds(number);
|
|
97
|
+
case TIME_UNIT_PROPERTY.YEAR:
|
|
98
|
+
return hoursToYears(number);
|
|
99
|
+
default:
|
|
100
|
+
return number || 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Converts month number to another time unit
|
|
105
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
106
|
+
* @param {number} number the number to convert
|
|
107
|
+
* @returns the converted number
|
|
108
|
+
*/
|
|
109
|
+
function monthConversion(to, number) {
|
|
110
|
+
switch (to) {
|
|
111
|
+
case TIME_UNIT_PROPERTY.DAY:
|
|
112
|
+
return monthsToDays(number);
|
|
113
|
+
case TIME_UNIT_PROPERTY.HOUR:
|
|
114
|
+
return monthsToHours(number);
|
|
115
|
+
case TIME_UNIT_PROPERTY.MINUTE:
|
|
116
|
+
return monthsToMinutes(number);
|
|
117
|
+
case TIME_UNIT_PROPERTY.SECOND:
|
|
118
|
+
return monthsToSeconds(number);
|
|
119
|
+
case TIME_UNIT_PROPERTY.YEAR:
|
|
120
|
+
return monthsToYears(number);
|
|
121
|
+
default:
|
|
122
|
+
return number || 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Converts minute number to another time unit
|
|
127
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
128
|
+
* @param {number} number the number to convert
|
|
129
|
+
* @returns the converted number
|
|
130
|
+
*/
|
|
131
|
+
function minuteConversion(to, number) {
|
|
132
|
+
switch (to) {
|
|
133
|
+
case TIME_UNIT_PROPERTY.DAY:
|
|
134
|
+
return minutesToDays(number);
|
|
135
|
+
case TIME_UNIT_PROPERTY.HOUR:
|
|
136
|
+
return minutesToHours(number);
|
|
137
|
+
case TIME_UNIT_PROPERTY.MONTH:
|
|
138
|
+
return minutesToMonths(number);
|
|
139
|
+
case TIME_UNIT_PROPERTY.SECOND:
|
|
140
|
+
return minutesToSeconds(number);
|
|
141
|
+
case TIME_UNIT_PROPERTY.YEAR:
|
|
142
|
+
return minutesToYears(number);
|
|
143
|
+
default:
|
|
144
|
+
return number || 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Converts year number to another time unit
|
|
149
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
150
|
+
* @param {number} number the number to convert
|
|
151
|
+
* @returns the converted number
|
|
152
|
+
*/
|
|
153
|
+
function yearConversion(to, number) {
|
|
154
|
+
switch (to) {
|
|
155
|
+
case TIME_UNIT_PROPERTY.DAY:
|
|
156
|
+
return yearsToDays(number);
|
|
157
|
+
case TIME_UNIT_PROPERTY.HOUR:
|
|
158
|
+
return yearsToHours(number);
|
|
159
|
+
case TIME_UNIT_PROPERTY.MINUTE:
|
|
160
|
+
return yearsToMinutes(number);
|
|
161
|
+
case TIME_UNIT_PROPERTY.MONTH:
|
|
162
|
+
return yearsToMonths(number);
|
|
163
|
+
case TIME_UNIT_PROPERTY.SECOND:
|
|
164
|
+
return yearsToSeconds(number);
|
|
165
|
+
default:
|
|
166
|
+
return number || 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Converts second number to another time unit
|
|
171
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
172
|
+
* @param {number} number the number to convert
|
|
173
|
+
* @returns the converted number
|
|
174
|
+
*/
|
|
175
|
+
function secondConversion(to, number) {
|
|
176
|
+
switch (to) {
|
|
177
|
+
case TIME_UNIT_PROPERTY.DAY:
|
|
178
|
+
return secondsToDays(number);
|
|
179
|
+
case TIME_UNIT_PROPERTY.HOUR:
|
|
180
|
+
return secondsToHours(number);
|
|
181
|
+
case TIME_UNIT_PROPERTY.MINUTE:
|
|
182
|
+
return secondsToMinutes(number);
|
|
183
|
+
case TIME_UNIT_PROPERTY.MONTH:
|
|
184
|
+
return secondsToMonths(number);
|
|
185
|
+
case TIME_UNIT_PROPERTY.YEAR:
|
|
186
|
+
return secondsToYears(number);
|
|
187
|
+
default:
|
|
188
|
+
return number || 0;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Validates the given arguments
|
|
193
|
+
* @param {ITimeUnitProperty} from a time unit
|
|
194
|
+
* @param {ITimeUnitProperty} to a time unit
|
|
195
|
+
* @param {number} number the number to convert
|
|
196
|
+
* @returns the converted number
|
|
197
|
+
*/
|
|
198
|
+
function validateArgumentts(from, to, number) {
|
|
199
|
+
return (isEmpty(from) || isEmpty(to)) && isNaNV2(number);
|
|
200
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in days to hours
|
|
7
|
+
* @param num the number in days
|
|
8
|
+
* @returns the number in hours
|
|
9
|
+
*/
|
|
10
|
+
export function daysToHours(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ days: num }).asHours();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in days to minutes
|
|
7
|
+
* @param num the number in days
|
|
8
|
+
* @returns the number in minutes
|
|
9
|
+
*/
|
|
10
|
+
export function daysToMinutes(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ days: num }).asMinutes();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in days to months
|
|
7
|
+
* @param num the number in days
|
|
8
|
+
* @returns the number in months
|
|
9
|
+
*/
|
|
10
|
+
export function daysToMonths(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ days: num }).asMonths();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in days to seconds
|
|
7
|
+
* @param num the number in days
|
|
8
|
+
* @returns the number in seconds
|
|
9
|
+
*/
|
|
10
|
+
export function daysToSeconds(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ days: num }).asSeconds();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in days to years
|
|
7
|
+
* @param num the number in days
|
|
8
|
+
* @returns the number in years
|
|
9
|
+
*/
|
|
10
|
+
export function daysToYears(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ days: num }).asYears();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in hours to days
|
|
7
|
+
* @param num the number in hours
|
|
8
|
+
* @returns the number in days
|
|
9
|
+
*/
|
|
10
|
+
export function hoursToDays(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ hours: num }).asDays();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in hours to minutes
|
|
7
|
+
* @param num the number in hours
|
|
8
|
+
* @returns the number in minutes
|
|
9
|
+
*/
|
|
10
|
+
export function hoursToMinutes(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ hours: num }).asMinutes();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in hours to months
|
|
7
|
+
* @param num the number in hours
|
|
8
|
+
* @returns the number in months
|
|
9
|
+
*/
|
|
10
|
+
export function hoursToMonths(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ hours: num }).asMonths();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in hours to seconds
|
|
7
|
+
* @param num the number in hours
|
|
8
|
+
* @returns the number in seconds
|
|
9
|
+
*/
|
|
10
|
+
export function hoursToSeconds(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ hours: num }).asSeconds();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in hours to years
|
|
7
|
+
* @param num the number in hours
|
|
8
|
+
* @returns the number in years
|
|
9
|
+
*/
|
|
10
|
+
export function hoursToYears(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ hours: num }).asYears();
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from "./adaptTimeUnitNumbers";
|
|
2
|
+
export * from "./daysToHours";
|
|
3
|
+
export * from "./daysToMinutes";
|
|
4
|
+
export * from "./daysToMonths";
|
|
5
|
+
export * from "./daysToSeconds";
|
|
6
|
+
export * from "./daysToYears";
|
|
7
|
+
export * from "./hoursToDays";
|
|
8
|
+
export * from "./hoursToMinutes";
|
|
9
|
+
export * from "./hoursToMonths";
|
|
10
|
+
export * from "./hoursToSeconds";
|
|
11
|
+
export * from "./hoursToYears";
|
|
12
|
+
export * from "./minutesToDays";
|
|
13
|
+
export * from "./minutesToHours";
|
|
14
|
+
export * from "./minutesToMonths";
|
|
15
|
+
export * from "./minutesToSeconds";
|
|
16
|
+
export * from "./minutesToYears";
|
|
17
|
+
export * from "./monthsToDays";
|
|
18
|
+
export * from "./monthsToHours";
|
|
19
|
+
export * from "./monthsToMinutes";
|
|
20
|
+
export * from "./monthsToSeconds";
|
|
21
|
+
export * from "./monthsToYears";
|
|
22
|
+
export * from "./secondsToDays";
|
|
23
|
+
export * from "./secondsToHours";
|
|
24
|
+
export * from "./secondsToMinutes";
|
|
25
|
+
export * from "./secondsToMonths";
|
|
26
|
+
export * from "./secondsToYears";
|
|
27
|
+
export * from "./yearsToDays";
|
|
28
|
+
export * from "./yearsToHours";
|
|
29
|
+
export * from "./yearsToMinutes";
|
|
30
|
+
export * from "./yearsToMonths";
|
|
31
|
+
export * from "./yearsToSeconds";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from "./adaptTimeUnitNumbers";
|
|
2
|
+
export * from "./daysToHours";
|
|
3
|
+
export * from "./daysToMinutes";
|
|
4
|
+
export * from "./daysToMonths";
|
|
5
|
+
export * from "./daysToSeconds";
|
|
6
|
+
export * from "./daysToYears";
|
|
7
|
+
export * from "./hoursToDays";
|
|
8
|
+
export * from "./hoursToMinutes";
|
|
9
|
+
export * from "./hoursToMonths";
|
|
10
|
+
export * from "./hoursToSeconds";
|
|
11
|
+
export * from "./hoursToYears";
|
|
12
|
+
export * from "./minutesToDays";
|
|
13
|
+
export * from "./minutesToHours";
|
|
14
|
+
export * from "./minutesToMonths";
|
|
15
|
+
export * from "./minutesToSeconds";
|
|
16
|
+
export * from "./minutesToYears";
|
|
17
|
+
export * from "./monthsToDays";
|
|
18
|
+
export * from "./monthsToHours";
|
|
19
|
+
export * from "./monthsToMinutes";
|
|
20
|
+
export * from "./monthsToSeconds";
|
|
21
|
+
export * from "./monthsToYears";
|
|
22
|
+
export * from "./secondsToDays";
|
|
23
|
+
export * from "./secondsToHours";
|
|
24
|
+
export * from "./secondsToMinutes";
|
|
25
|
+
export * from "./secondsToMonths";
|
|
26
|
+
export * from "./secondsToYears";
|
|
27
|
+
export * from "./yearsToDays";
|
|
28
|
+
export * from "./yearsToHours";
|
|
29
|
+
export * from "./yearsToMinutes";
|
|
30
|
+
export * from "./yearsToMonths";
|
|
31
|
+
export * from "./yearsToSeconds";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in minutes to days
|
|
7
|
+
* @param num the number in minutes
|
|
8
|
+
* @returns the number in days
|
|
9
|
+
*/
|
|
10
|
+
export function minutesToDays(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ minutes: num }).asDays();
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import duration from "dayjs/plugin/duration";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { isNaNV2 } from "../../general/mix/isNaNV2";
|
|
5
|
+
/**
|
|
6
|
+
* Converts the number in minutes to hours
|
|
7
|
+
* @param num the number in minutes
|
|
8
|
+
* @returns the number in hours
|
|
9
|
+
*/
|
|
10
|
+
export function minutesToHours(num) {
|
|
11
|
+
dayjs.extend(duration);
|
|
12
|
+
if (isEmpty(num) || isNaNV2(num))
|
|
13
|
+
return 0;
|
|
14
|
+
return dayjs.duration({ minutes: num }).asHours();
|
|
15
|
+
}
|