diff --git a/bower.json b/bower.json index 58e62a0769..8d0e266c2f 100644 --- a/bower.json +++ b/bower.json @@ -18,6 +18,7 @@ "bootstrap": "~3.3.4", "font-awesome": "~4.3.0", "moment": "~2.10.2", + "moment-timezone": "~0.5.0", "jshint": "~2.9.0", "lightbox2": "~2.8.1", "rxjs": "~4.0.6", diff --git a/client/commonFramework/show-completion.js b/client/commonFramework/show-completion.js index 5080efd629..752938993a 100644 --- a/client/commonFramework/show-completion.js +++ b/client/commonFramework/show-completion.js @@ -1,6 +1,7 @@ window.common = (function(global) { const { $, + moment, ga = (() => {}), common = { init: [] } } = global; @@ -51,7 +52,8 @@ window.common = (function(global) { name: common.challengeName, completedWith: didCompleteWith, challengeType: common.challengeType, - solution + solution, + timezone: moment.tz.guess() }; $.post('/completed-challenge/', data, function(res) { diff --git a/common/models/user.json b/common/models/user.json index 66a42f437b..ad68b5c2fb 100644 --- a/common/models/user.json +++ b/common/models/user.json @@ -173,6 +173,9 @@ }, "tshirtVote": { "type": "number" + }, + "timezone": { + "type": "string" } }, "validations": [], diff --git a/gulpfile.js b/gulpfile.js index 5069c1bca0..4b87263ad1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -99,6 +99,7 @@ var paths = { 'public/bower_components/bootstrap/dist/js/bootstrap.min.js', 'public/bower_components/d3/d3.min.js', 'public/bower_components/moment/min/moment.min.js', + 'public/bower_components/moment-timezone/builds/moment-timezone-with-data.min.js', 'public/bower_components/mousetrap/mousetrap.min.js', 'public/bower_components/lightbox2/dist/js/lightbox.min.js', 'public/bower_components/rxjs/dist/rx.all.min.js' diff --git a/package.json b/package.json index 8ec11c6ca5..bdb047d58b 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "merge-stream": "^1.0.0", "method-override": "^2.3.0", "moment": "^2.10.2", + "moment-timezone": "^0.5.0", "mongodb": "^2.0.33", "morgan": "^1.6.1", "node-uuid": "^1.4.3", diff --git a/server/boot/challenge.js b/server/boot/challenge.js index df0ad21d8a..bf26a8a78b 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -505,7 +505,8 @@ module.exports = function(app) { id, name, challengeType, - solution + solution, + timezone } = req.body; const { alreadyCompleted } = updateUserProgress( @@ -521,6 +522,10 @@ module.exports = function(app) { } ); + if (timezone && (!req.user.timezone || req.user.timezone != timezone)) { + req.user.timezone = timezone; + } + let user = req.user; saveUser(req.user) .subscribe( diff --git a/server/boot/user.js b/server/boot/user.js index a4924fe6d8..e4c9061d35 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -1,6 +1,6 @@ import _ from 'lodash'; import dedent from 'dedent'; -import moment from 'moment'; +import moment from 'moment-timezone'; import { Observable } from 'rx'; import debugFactory from 'debug'; @@ -38,6 +38,8 @@ const certText = { [certTypes.fullStack]: 'Full Stack Certified' }; +const dateFormat = 'MMM DD, YYYY'; + function replaceScriptTags(value) { return value .replace(/