Skip to content

Commit

Permalink
create areDatesIdentical and getTimePeriod
Browse files Browse the repository at this point in the history
  • Loading branch information
perunt committed Aug 23, 2023
1 parent f532d24 commit 9e8e850
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/libs/DateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -402,6 +421,8 @@ const DateUtils = {
extractTime12Hour,
setTimeOrDefaultToTomorrow,
parseTimeTo12HourFormat,
areDatesIdentical,
getTimePeriod,
};

export default DateUtils;

0 comments on commit 9e8e850

Please sign in to comment.