2016-10-19 03:30:46 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const expect = require("chai").expect;
|
2016-12-18 15:53:28 +00:00
|
|
|
const localetime = require("../../../../../client/js/libs/handlebars/localetime");
|
2016-10-19 03:30:46 +00:00
|
|
|
|
|
|
|
describe("localetime Handlebars helper", () => {
|
|
|
|
it("should render a human-readable date", () => {
|
|
|
|
// 12PM in UTC time
|
|
|
|
const date = new Date("2014-05-22T12:00:00");
|
|
|
|
|
|
|
|
// Offset between UTC and local timezone
|
|
|
|
const offset = date.getTimezoneOffset() * 60 * 1000;
|
|
|
|
|
|
|
|
// Pretend local timezone is UTC by moving the clock of that offset
|
|
|
|
const time = date.getTime() + offset;
|
|
|
|
|
2017-04-29 10:31:04 +00:00
|
|
|
expect(localetime(time)).to.equal("22 May 2014, 12:00:00");
|
2016-10-19 03:30:46 +00:00
|
|
|
});
|
|
|
|
});
|