From 40a4f8caba5b2296a82be6784af2054cd7253721 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Wed, 22 Jul 2015 16:37:11 -0600 Subject: [PATCH] * Add missing modules to package.json * Start replacing some code with momentjs --- core/mci_view_factory.js | 4 +++- core/menu_module.js | 10 +++++++--- core/user.js | 7 ++++++- package.json | 4 +++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/core/mci_view_factory.js b/core/mci_view_factory.js index 4e10517f..9b99de8a 100644 --- a/core/mci_view_factory.js +++ b/core/mci_view_factory.js @@ -20,6 +20,7 @@ var packageJson = require('../package.json'); var assert = require('assert'); var os = require('os'); var _ = require('lodash'); +var moment = require('moment'); exports.MCIViewFactory = MCIViewFactory; @@ -39,7 +40,8 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) { UR : this.client.user.properties.real_name, LO : this.client.user.properties.location, UA : this.client.user.getAge().toString(), - UB : this.client.user.getFormattedBirthDate('medium'), + UB : moment(this.client.user.properties.birthdate).format('MM/DD/YYYY'), + //UB : this.client.user.getFormattedBirthDate('medium'), US : this.client.user.properties.sex, UE : this.client.user.properties.email_address, UW : this.client.user.properties.web_address, diff --git a/core/menu_module.js b/core/menu_module.js index a5f060a7..85b1737f 100644 --- a/core/menu_module.js +++ b/core/menu_module.js @@ -43,7 +43,7 @@ function MenuModule(options) { switch(artAsset.type) { case 'art' : theme.displayThemeArt(dispOptions, function displayed(err, themeArtData) { - cb(err, { mciMap : themeArtData.mciMap, height : themeArtData.extraInfo.height } ); + cb(err, err ? null : { mciMap : themeArtData.mciMap, height : themeArtData.extraInfo.height } ); }); break; @@ -77,7 +77,9 @@ function MenuModule(options) { function displayMenuArt(callback) { if(_.isString(self.menuConfig.art)) { self.displayArtAsset(self.menuConfig.art, function displayed(err, artData) { - mciData.menu = artData.mciMap; + if(!err) { + mciData.menu = artData.mciMap; + } callback(err); }); } else { @@ -103,7 +105,9 @@ function MenuModule(options) { // :TODO: allow inline prompts in the future, e.g. @inline:memberName -> { "memberName" : { "text" : "stuff", ... } } var promptConfig = self.menuConfig.promptConfig; self.displayArtAsset(promptConfig.art, function displayed(err, artData) { - mciData.prompt = artData.mciMap; + if(!err) { + mciData.prompt = artData.mciMap; + } callback(err); }); } else { diff --git a/core/user.js b/core/user.js index 5788ff4d..d10f4edf 100644 --- a/core/user.js +++ b/core/user.js @@ -9,6 +9,7 @@ var crypto = require('crypto'); var assert = require('assert'); var async = require('async'); var _ = require('lodash'); +var moment = require('moment'); exports.User = User; exports.getUserIdAndName = getUserIdAndName; @@ -333,7 +334,10 @@ User.prototype.getFormattedBirthDate = function(style) { }; User.prototype.getAge = function() { - var birthDate = new Date(Date.parse(this.properties.birthdate)); + 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(); @@ -344,6 +348,7 @@ User.prototype.getAge = function() { return age; } + */ }; /////////////////////////////////////////////////////////////////////////////// diff --git a/package.json b/package.json index 1fa2439e..5d5f361a 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,9 @@ "ssh2" : "0.4.x", "strip-json-comments" : "1.0.x", "gapbuffer" : "0.0.2", - "node-uuid" : "1.4.x" + "node-uuid" : "1.4.x", + "moment" : "2.10.x", + "gaze" : "0.5.x" }, "engine" : "node >= 0.12.2" } \ No newline at end of file