Skip to content

Commit

Permalink
Merge pull request #1349 from finos/fix-timezone-tests
Browse files Browse the repository at this point in the history
Fix timezone tests to take DST into account
  • Loading branch information
texodus authored Mar 17, 2021
2 parents acd55a4 + 039fafe commit da04163
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/perspective/test/js/timezone/timezone.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@ const check_datetime = (output, expected) => {
describe("Timezone Tests", () => {
beforeAll(() => {
expect(process.env.TZ).toBe("America/New_York");
expect(new Date().getTimezoneOffset()).toBe(300);
const now = new Date();

// offset is 240 during DST and 300 during non-DST, since we manually
// set the timezone here just assert the timezone string

if (now.toString().includes("GMT-0400") || now.toString().includes("Eastern Daylight Time")) {
expect(new Date().getTimezoneOffset()).toBe(240);
} else {
expect(new Date().getTimezoneOffset()).toBe(300);
}

console.log("Timezone set to", process.env.TZ);
});

Expand Down

0 comments on commit da04163

Please sign in to comment.