2022-06-18 20:25:21 -04:00
|
|
|
import {expect} from "chai";
|
|
|
|
import localetime from "../../../../client/js/helpers/localetime";
|
2016-10-18 23:30:46 -04:00
|
|
|
|
2019-11-05 05:36:44 -05:00
|
|
|
describe("localetime helper", () => {
|
2016-10-18 23:30:46 -04:00
|
|
|
it("should render a human-readable date", () => {
|
|
|
|
// 12PM in UTC time
|
2017-06-03 03:29:52 -04:00
|
|
|
const date = new Date("2014-05-22T12:00:00Z");
|
2016-10-18 23:30:46 -04: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 06:31:04 -04:00
|
|
|
expect(localetime(time)).to.equal("22 May 2014, 12:00:00");
|
2016-10-18 23:30:46 -04:00
|
|
|
});
|
|
|
|
});
|