mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-23 19:20:41 +02:00
* Some code cleanup
This commit is contained in:
parent
4505ad17e2
commit
7f4c97329d
2 changed files with 4 additions and 29 deletions
25
core/user.js
25
core/user.js
|
@ -320,35 +320,10 @@ User.prototype.persistProperties = function(cb) {
|
|||
});
|
||||
};
|
||||
|
||||
// :TODO: A general purpose date/time formatting class or lib would be better here....
|
||||
User.prototype.getFormattedBirthDate = function(style) {
|
||||
style = style || 'medium';
|
||||
|
||||
switch(style) {
|
||||
|
||||
case 'medium' :
|
||||
return _.has(this.properties, 'birthdate') ?
|
||||
new Date(Date.parse(this.properties.birthdate)).toJSON().slice(0, 10) :
|
||||
null;
|
||||
}
|
||||
};
|
||||
|
||||
User.prototype.getAge = function() {
|
||||
if(_.has(this.properties, 'birthdate')) {
|
||||
return moment().diff(this.properties.birthdate, 'years');
|
||||
}
|
||||
/*
|
||||
if(!isNaN(birthDate)) {
|
||||
var today = new Date();
|
||||
var age = today.getFullYear() - birthDate.getFullYear();
|
||||
var m = today.getMonth() - birthDate.getMonth();
|
||||
if(m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
|
||||
age--;
|
||||
}
|
||||
|
||||
return age;
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue