Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include IANA timezone canonical name in TimeZoneInfo (#27591)
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
process.env.TZ = 'UTC'; | ||
|
||
module.exports = { | ||
verbose: false, | ||
transform: { | ||
|
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,31 @@ | ||
import { getTimeZoneInfo } from './timezones'; | ||
import { setTimeZoneResolver } from './common'; | ||
|
||
describe('getTimeZoneInfo', () => { | ||
// global timezone is set to UTC, see jest-config.js file | ||
|
||
describe('IANA canonical name of the timezone', () => { | ||
it('should resolve for default timezone', () => { | ||
setTimeZoneResolver(() => 'browser'); | ||
const result = getTimeZoneInfo('', Date.now()); | ||
expect(result?.ianaName).toBe('Africa/Abidjan'); | ||
}); | ||
|
||
it('should resolve for browser timezone', () => { | ||
// global timezone is set to UTC | ||
const result = getTimeZoneInfo('browser', Date.now()); | ||
expect(result?.ianaName).toBe('Africa/Abidjan'); | ||
}); | ||
it('should resolve for utc timezone', () => { | ||
// global timezone is set to UTC | ||
const result = getTimeZoneInfo('utc', Date.now()); | ||
expect(result?.ianaName).toBe('UTC'); | ||
}); | ||
|
||
it('should resolve for given timezone', () => { | ||
// global timezone is set to UTC | ||
const result = getTimeZoneInfo('Europe/Warsaw', Date.now()); | ||
expect(result?.ianaName).toBe('Europe/Warsaw'); | ||
}); | ||
}); | ||
}); |
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