diff --git a/client/js/libs/handlebars/friendlydate.js b/client/js/libs/handlebars/friendlydate.js index 92e81080..60d8f402 100644 --- a/client/js/libs/handlebars/friendlydate.js +++ b/client/js/libs/handlebars/friendlydate.js @@ -4,10 +4,10 @@ const moment = require("moment"); module.exports = function(time) { // See http://momentjs.com/docs/#/displaying/calendar-time/ - return moment(new Date(time)).calendar(null, { + return moment(time).calendar(null, { sameDay: "[Today]", lastDay: "[Yesterday]", - lastWeek: "L", // Locale - sameElse: "L" + lastWeek: "D MMMM YYYY", + sameElse: "D MMMM YYYY" }); }; diff --git a/client/js/libs/handlebars/localedate.js b/client/js/libs/handlebars/localedate.js index 9c800ab0..3e6f7285 100644 --- a/client/js/libs/handlebars/localedate.js +++ b/client/js/libs/handlebars/localedate.js @@ -1,5 +1,7 @@ "use strict"; +const moment = require("moment"); + module.exports = function(time) { - return new Date(time).toLocaleDateString(); + return moment(time).format("D MMMM YYYY"); }; diff --git a/client/js/libs/handlebars/localetime.js b/client/js/libs/handlebars/localetime.js index 59e1dbf8..17a6043d 100644 --- a/client/js/libs/handlebars/localetime.js +++ b/client/js/libs/handlebars/localetime.js @@ -1,5 +1,7 @@ "use strict"; +const moment = require("moment"); + module.exports = function(time) { - return new Date(time).toLocaleString(); + return moment(time).format("D MMMM YYYY, HH:mm:ss"); }; diff --git a/client/js/libs/handlebars/tz.js b/client/js/libs/handlebars/tz.js index e62bf285..77feaaff 100644 --- a/client/js/libs/handlebars/tz.js +++ b/client/js/libs/handlebars/tz.js @@ -1,17 +1,7 @@ "use strict"; +const moment = require("moment"); + module.exports = function(time) { - time = new Date(time); - var h = time.getHours(); - var m = time.getMinutes(); - - if (h < 10) { - h = "0" + h; - } - - if (m < 10) { - m = "0" + m; - } - - return h + ":" + m; + return moment(time).format("HH:mm"); }; diff --git a/test/client/js/libs/handlebars/friendlydateTest.js b/test/client/js/libs/handlebars/friendlydateTest.js index 16f335c3..6e76003e 100644 --- a/test/client/js/libs/handlebars/friendlydateTest.js +++ b/test/client/js/libs/handlebars/friendlydateTest.js @@ -18,7 +18,7 @@ describe("friendlydate Handlebars helper", () => { it("should not render any friendly dates prior to the day before", () => { [2, 7, 30, 365, 1000].forEach(day => { const time = new Date().getTime() - 24 * 3600 * 1000 * day; - expect(friendlydate(time)).to.equal(moment(time).format("L")); + expect(friendlydate(time)).to.equal(moment(time).format("D MMMM YYYY")); }); }); }); diff --git a/test/client/js/libs/handlebars/localetimeTest.js b/test/client/js/libs/handlebars/localetimeTest.js index bccf3649..cd0a7ef9 100644 --- a/test/client/js/libs/handlebars/localetimeTest.js +++ b/test/client/js/libs/handlebars/localetimeTest.js @@ -14,6 +14,6 @@ describe("localetime Handlebars helper", () => { // Pretend local timezone is UTC by moving the clock of that offset const time = date.getTime() + offset; - expect(localetime(time)).to.equal("5/22/2014, 12:00:00 PM"); + expect(localetime(time)).to.equal("22 May 2014, 12:00:00"); }); });