Fix timezone names

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-05-29 21:49:14 +02:00
parent 827a71b950
commit c37f76282b
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 4 additions and 2 deletions

View File

@ -32,7 +32,8 @@ export function getSortedTimezoneList(timezoneList = [], additionalTimezones = [
const sortedList = []
for (const timezoneId of timezoneList) {
let [continent, name] = timezoneId.split('/', 2)
const components = timezoneId.split('/')
let [continent, name] = [components.shift(), components.join('/')]
if (!name) {
name = continent
// TRANSLATORS This refers to global timezones in the timezone picker

View File

@ -115,9 +115,10 @@ describe('utils/timezone test suite', () => {
expect(translate).toHaveBeenNthCalledWith(3, 'calendar', 'Global')
})
it ('should get a readable timezone name', () => {
it('should get a readable timezone name', () => {
expect(getReadableTimezoneName('Europe/Berlin')).toEqual('Europe - Berlin')
expect(getReadableTimezoneName('America/New_York')).toEqual('America - New York')
expect(getReadableTimezoneName('America/St_Johns')).toEqual('America - St. Johns')
expect(getReadableTimezoneName('America/Argentina/Buenos_Aires')).toEqual('America - Argentina - Buenos Aires')
})
})