/**
* Date utility functions
* @module
* @since 0.1.0
*/
/**
* Work out the difference between 2 dates
* @param {string} unit The unit you want to the difference i.e days, months, years
* @param {date} date_from Date to start
* @param {date} date_to Date to finish
* @returns {number} Unit between start and end dates
*/
const dateDifference = (unit, date_from, date_to) => {
if (unit === 'months') {
return date_to.getMonth() - date_from.getMonth()
+ (12 * (date_to.getFullYear() - date_from.getFullYear()));
}
throw new Error('Unknown unit passed in to dateDifference function');
};
export {
dateDifference,
};