-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ui] Use TZ offset to display cron string for user timezone
- Loading branch information
Showing
12 changed files
with
248 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
js_modules/dagster-ui/packages/ui-core/src/schedules/__tests__/hourOffsetFromUTC.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {hourOffsetFromUTC} from '../hourOffsetFromUTC'; | ||
|
||
describe('hourOffsetFromUTC', () => { | ||
const JUL_1_2024_9_AM_CDT = new Date('2024-07-01T15:00:00.000Z'); | ||
const NOV_5_2024_9_AM_CST = new Date('2024-11-05T15:00:00.000Z'); | ||
|
||
beforeAll(() => { | ||
jest.useFakeTimers(); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.useRealTimers(); | ||
}); | ||
|
||
describe('Standard time in Northern Hemisphere', () => { | ||
beforeEach(() => { | ||
jest.setSystemTime(NOV_5_2024_9_AM_CST); | ||
}); | ||
|
||
it('returns the offset for a given timezone', () => { | ||
// Timezones with DST in Northern Hemisphere: | ||
expect(hourOffsetFromUTC('America/New_York')).toBe(-5); | ||
expect(hourOffsetFromUTC('America/Los_Angeles')).toBe(-8); | ||
expect(hourOffsetFromUTC('America/St_Johns')).toBe(-3.5); | ||
|
||
// Timezones without DST: | ||
expect(hourOffsetFromUTC('UTC')).toBe(0); | ||
expect(hourOffsetFromUTC('Europe/Berlin')).toBe(1); | ||
expect(hourOffsetFromUTC('Asia/Tokyo')).toBe(9); | ||
expect(hourOffsetFromUTC('Asia/Shanghai')).toBe(8); | ||
|
||
// Timezones with DST in Southern Hemisphere: | ||
expect(hourOffsetFromUTC('America/Santiago')).toBe(-3); | ||
expect(hourOffsetFromUTC('Australia/Adelaide')).toBe(10.5); | ||
}); | ||
}); | ||
|
||
describe('Daylight savings time in Northern Hemisphere', () => { | ||
beforeEach(() => { | ||
jest.setSystemTime(JUL_1_2024_9_AM_CDT); | ||
}); | ||
|
||
it('returns the offset for a given timezone', () => { | ||
// Timezones with DST in Northern Hemisphere: | ||
expect(hourOffsetFromUTC('America/New_York')).toBe(-4); | ||
expect(hourOffsetFromUTC('America/Los_Angeles')).toBe(-7); | ||
expect(hourOffsetFromUTC('America/St_Johns')).toBe(-2.5); | ||
expect(hourOffsetFromUTC('Europe/Berlin')).toBe(2); | ||
|
||
// Timezones without DST: | ||
expect(hourOffsetFromUTC('UTC')).toBe(0); | ||
expect(hourOffsetFromUTC('Asia/Tokyo')).toBe(9); | ||
expect(hourOffsetFromUTC('Asia/Shanghai')).toBe(8); | ||
|
||
// Timezones with DST in Southern Hemisphere: | ||
expect(hourOffsetFromUTC('America/Santiago')).toBe(-4); | ||
expect(hourOffsetFromUTC('Australia/Adelaide')).toBe(9.5); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.