Home | History | Annotate | Download | only in regress
      1 // Copyright 2015 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 if (this.Intl) {
      6   // chromium:364374
      7 
      8   // Locations with 2 underscores are accepted and normalized.
      9   // 'of' and 'es' are always lowercased.
     10   df = new Intl.DateTimeFormat('en-US', {'timeZone': 'eUrope/isLe_OF_man'})
     11   assertEquals('Europe/Isle_of_Man', df.resolvedOptions().timeZone);
     12 
     13   df = new Intl.DateTimeFormat('en-US', {'timeZone': 'africa/Dar_eS_salaam'})
     14   assertEquals('Africa/Dar_es_Salaam', df.resolvedOptions().timeZone);
     15 
     16   df = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/port_of_spain'})
     17   assertEquals('America/Port_of_Spain', df.resolvedOptions().timeZone);
     18 
     19   // Zone ids with more than 2 parts are accepted and normalized.
     20   df = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/north_Dakota/new_salem'})
     21   assertEquals('America/North_Dakota/New_Salem', df.resolvedOptions().timeZone);
     22 
     23   // 3-part zone IDs are accepted and normalized.
     24   // Two Buenose Aires aliases are identical.
     25   df1 = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/aRgentina/buenos_aIres'})
     26   df2 = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/Argentina/Buenos_Aires'})
     27   assertEquals(df1.resolvedOptions().timeZone, df2.resolvedOptions().timeZone);
     28 
     29   df2 = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/Buenos_Aires'})
     30   assertEquals(df1.resolvedOptions().timeZone, df2.resolvedOptions().timeZone);
     31 
     32   df1 = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/Indiana/Indianapolis'})
     33   df2 = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/Indianapolis'})
     34   assertEquals(df1.resolvedOptions().timeZone, df2.resolvedOptions().timeZone);
     35 
     36   // ICU does not recognize East-Indiana. Add later when it does.
     37   // df2 = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/East-Indiana'})
     38   // assertEquals(df1.resolvedOptions().timeZone, df2.resolvedOptions().timeZone);
     39 
     40 
     41   // Zone IDs with hyphens. 'au' has to be in lowercase.
     42   df = new Intl.DateTimeFormat('en-US', {'timeZone': 'America/port-aU-pRince'})
     43   assertEquals('America/Port-au-Prince', df.resolvedOptions().timeZone);
     44 
     45   // Accepts Ho_Chi_Minh and treats it as identical to Saigon
     46   df1 = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Ho_Chi_Minh'})
     47   df2 = new Intl.DateTimeFormat('en-US', {'timeZone': 'Asia/Saigon'})
     48   assertEquals(df1.resolvedOptions().timeZone, df2.resolvedOptions().timeZone);
     49 
     50   // Throws for invalid timezone ids.
     51   assertThrows(() => Intl.DateTimeFormat(undefined, {timeZone: 'Europe/_Paris'}));
     52   assertThrows(() => Intl.DateTimeFormat(undefined, {timeZone: 'America/New__York'}));
     53   assertThrows(() => Intl.DateTimeFormat(undefined, {timeZone: 'America//New_York'}));
     54   assertThrows(() => Intl.DateTimeFormat(undefined, {timeZone: 'America/New_York_'}));
     55   assertThrows(() => Intl.DateTimeFormat(undefined, {timeZone: 'America/New_Y0rk'}));
     56 }
     57