index.js
function getDateDifference(timestr1, timestr2) {
	// Force into predictable date format
	var start = timestr1.toLocaleDateString ? timestr1 : new Date(timestr1);
	var end = timestr2.toLocaleDateString ? timestr2 : new Date(timestr2);

	if (start.toString() === 'Invalid Date' || end.toString() === 'Invalid Date') {
		throw new TypeError('pendel.date() expects two valid date strings');
	}

	var dr = moment.range(start, end);

	return {
		years: dr.diff('years'),
		months: dr.diff('months'),
		weeks: dr.diff('weeks'),
		days: dr.diff('days'),
		hours: dr.diff('hours'),
		minutes: dr.diff('minutes'),
		seconds: dr.diff('seconds')
	};
}
function getDateDifference(timestr1, timestr2) {
	// Force into predictable date format
	var start = timestr1.toLocaleDateString ? timestr1 : new Date(timestr1);
	var end = timestr2.toLocaleDateString ? timestr2 : new Date(timestr2);

	if (start.toString() === 'Invalid Date' || end.toString() === 'Invalid Date') {
		throw new TypeError('pendel.date() expects two valid date strings');
	}

	var dr = moment.range(start, end);

	return {
		years: dr.diff('years'),
		months: dr.diff('months'),
		weeks: dr.diff('weeks'),
		days: dr.diff('days'),
		hours: dr.diff('hours'),
		minutes: dr.diff('minutes'),
		seconds: dr.diff('seconds')
	};
}
function getDateDifference ( timestr1 , timestr2 ) { // Force into predictable date format var start = timestr1 . toLocaleDateString ? timestr1 : new Date ( timestr1 ) ; var end = timestr2 . toLocaleDateString ? timestr2 : new Date ( timestr2 ) ; if ( start . toString ( ) === 'Invalid Date' || end . toString ( ) === 'Invalid Date' ) { throw new TypeError ( 'pendel.date() expects two valid date strings' ) ; } var dr = moment . range ( start , end ) ; return { years : dr . diff ( 'years' ) , months : dr . diff ( 'months' ) , weeks : dr . diff ( 'weeks' ) , days : dr . diff ( 'days' ) , hours : dr . diff ( 'hours' ) , minutes : dr . diff ( 'minutes' ) , seconds : dr . diff ( 'seconds' ) } ; }
Get the time difference between two datestrings.

@param {string} timestr1 - a date string.
@param {string} timestr2 - a date string.
@returns {object}
Get the time difference between two datestrings .