From e3185b9560775dbcb3d55e852417f9ef127e94f2 Mon Sep 17 00:00:00 2001 From: cmastudios Date: Wed, 1 Jan 2014 19:46:11 -0500 Subject: [PATCH] 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. --- src/routes/user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/user.js b/src/routes/user.js index dd5491b43e..144cf08508 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -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)); \ No newline at end of file +}(exports));