From 9e8e850e422571feafd4edeb4c74dbf9932eff96 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 23 Aug 2023 22:42:26 +0200 Subject: [PATCH] create areDatesIdentical and getTimePeriod --- src/libs/DateUtils.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/libs/DateUtils.js b/src/libs/DateUtils.js index a40eeb28c70b..0fda6f324c5c 100644 --- a/src/libs/DateUtils.js +++ b/src/libs/DateUtils.js @@ -287,8 +287,6 @@ function getDateBasedFromType(type) { return getEndOfToday(); case CONST.CUSTOM_STATUS_TYPES.AFTER_WEEK: return getEndOfWeekFromNow(); - case CONST.CUSTOM_STATUS_TYPES.NEVER: - return getOneHundredYearsFromNow(); default: return ''; } @@ -374,6 +372,27 @@ function parseTimeTo12HourFormat(datetime) { }; } +/** + * @param {String} dateStr + * @returns {String} + * @example + */ +function getTimePeriod(dateStr) { + return moment(dateStr).format('A'); +} + +/** + * @param {String} dateParam1 + * @param {String} dateParam2 + * @returns {Boolean} + */ +function areDatesIdentical(dateParam1, dateParam2) { + const date1 = moment(dateParam1); + const date2 = moment(dateParam2); + + return date1.isSame(date2); +} + /** * @namespace DateUtils */ @@ -402,6 +421,8 @@ const DateUtils = { extractTime12Hour, setTimeOrDefaultToTomorrow, parseTimeTo12HourFormat, + areDatesIdentical, + getTimePeriod, }; export default DateUtils;