Coverage

100%
12
12
0

/Users/sebastiansandqvist/Documents/Sites & Projects/apps/~modules/s-age/index.js

100%
12
12
0
LineHitsSource
11'use strict';
2
31module.exports = function(date) {
4
56 var type = Object.prototype.toString.call(date);
66 var now = new Date();
7
8 // convert dateStrings and timestamps to a Date
96 if (type === '[object String]' || type === '[object Number]') {
103 date = new Date(date);
11 }
12
136 var yearDiff = now.getFullYear() - date.getFullYear();
145 var monthDiff = now.getMonth() - date.getMonth();
155 var pastDate = now.getDate() < date.getDate();
16
175 if (monthDiff < 0 || (monthDiff === 0 && pastDate)) {
182 yearDiff--;
19 }
20
215 return yearDiff;
22
23};