mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
* MCI keys no longer consider view IDs as this implied order
* Converted all MCI keys in menu.json/etc., e.g. BN1ET2 -> BN1ET2 * Fix regression with prompt loading * 'age' property -> 'birthdate' * MaskEditView.getData() returns data with literals in place * Other minor changes
This commit is contained in:
parent
81e684cdcc
commit
735b572f9f
14 changed files with 93 additions and 32 deletions
27
core/user.js
27
core/user.js
|
@ -319,6 +319,33 @@ 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() {
|
||||
var birthDate = new Date(Date.parse(this.properties.birthdate));
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Exported methods
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue