Calculate age based on days instead of years

Calculating the age based on the year only caused issues in the display of the age because it was off. Example: Person who was born in march of 1999 is displayed as 15 instead of 14 after the turn of the year.
This commit is contained in:
cmastudios
2014-01-01 19:46:11 -05:00
parent 449adfae59
commit e3185b9560

View File

@@ -539,7 +539,7 @@ var fs = require('fs'),
if (!data.birthday) {
data.age = '';
} else {
data.age = new Date().getFullYear() - new Date(data.birthday).getFullYear();
data.age = Math.floor((new Date().getTime() - new Date(data.birthday).getTime()) / 31536000000);
}
function canSeeEmail() {
@@ -581,4 +581,4 @@ var fs = require('fs'),
};
}(exports));
}(exports));