Skip to content
Snippets Groups Projects
Commit fb7849ec authored by Mikkel Aas's avatar Mikkel Aas
Browse files

added a function that can compute months between two dates

parent f79e03a0
Branches
No related tags found
1 merge request!88Nav verifier extended
...@@ -14,3 +14,18 @@ export function computeYearsBetweenDates(date1: string, date2: string): number { ...@@ -14,3 +14,18 @@ export function computeYearsBetweenDates(date1: string, date2: string): number {
return Math.abs(yearDiff); return Math.abs(yearDiff);
} }
/**
* computeMonthsBetweenDates computes the month difference between two dates.
* @param date1 the first date as a string
* @param date2 the second date as a string
* @returns the absolute value of the month difference.
*/
export function computeMonthsBetweenDates(date1: string, date2: string): number{
const momentDate1 = moment(date1);
const momentDate2 = moment(date2);
const monthDiff = momentDate1.diff(momentDate2, 'months');
return Math.abs(monthDiff);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment