function canonicalizeTimeZoneID(tzID) {
  // Skip undefined zones.
  if (IS_UNDEFINED(tzID)) {
    return tzID;
  }

  // Special case handling (UTC, GMT).
  var upperID = %StringToUpperCase(tzID);
  if (upperID === 'UTC' || upperID === 'GMT' ||
      upperID === 'ETC/UTC' || upperID === 'ETC/GMT') {
    return 'UTC';
  }

  // TODO(jshin): Add support for Etc/GMT[+-]([1-9]|1[0-2])

  // We expect only _, '-' and / beside ASCII letters.
  // All inputs should conform to Area/Location(/Location)* from now on.
  var match = InternalRegExpMatch(GetTimezoneNameCheckRE(), tzID);
  if (IS_NULL(match)) throw MakeRangeError(kExpectedTimezoneID, tzID);

  var result = toTitleCaseTimezoneLocation(match[1]) + '/' +
               toTitleCaseTimezoneLocation(match[2]);

  if (!IS_UNDEFINED(match[3]) && 3 < match.length) {
    var locations = %_Call(StringSplit, match[3], '/');
    // The 1st element is empty. Starts with i=1.
    for (var i = 1; i < locations.length; i++) {
      result = result + '/' + toTitleCaseTimezoneLocation(locations[i]);
    }
  }

  return result;
}
function canonicalizeTimeZoneID(tzID) {
  
  if (IS_UNDEFINED(tzID)) {
    return tzID;
  }

  
  var upperID = %StringToUpperCase(tzID);
  if (upperID === 'UTC' || upperID === 'GMT' ||
      upperID === 'ETC/UTC' || upperID === 'ETC/GMT') {
    return 'UTC';
  }

  

  
  
  var match = InternalRegExpMatch(GetTimezoneNameCheckRE(), tzID);
  if (IS_NULL(match)) throw MakeRangeError(kExpectedTimezoneID, tzID);

  var result = toTitleCaseTimezoneLocation(match[1]) + '/' +
               toTitleCaseTimezoneLocation(match[2]);

  if (!IS_UNDEFINED(match[3]) && 3 < match.length) {
    var locations = %_Call(StringSplit, match[3], '/');
    
    for (var i = 1; i < locations.length; i++) {
      result = result + '/' + toTitleCaseTimezoneLocation(locations[i]);
    }
  }

  return result;
}
function canonicalizeTimeZoneID ( tzID ) { // Skip undefined zones. if ( IS_UNDEFINED ( tzID ) ) { return tzID ; } // Special case handling (UTC, GMT). var upperID = % StringToUpperCase ( tzID ) ; if ( upperID === 'UTC' || upperID === 'GMT' || upperID === 'ETC/UTC' || upperID === 'ETC/GMT' ) { return 'UTC' ; } // TODO(jshin): Add support for Etc/GMT[+-]([1-9]|1[0-2]) // We expect only _, '-' and / beside ASCII letters. // All inputs should conform to Area/Location(/Location)* from now on. var match = InternalRegExpMatch ( GetTimezoneNameCheckRE ( ) , tzID ) ; if ( IS_NULL ( match ) ) throw MakeRangeError ( kExpectedTimezoneID , tzID ) ; var result = toTitleCaseTimezoneLocation ( match [ 1 ] ) + '/' + toTitleCaseTimezoneLocation ( match [ 2 ] ) ; if ( ! IS_UNDEFINED ( match [ 3 ] ) && 3 < match . length ) { var locations = % _Call ( StringSplit , match [ 3 ] , '/' ) ; // The 1st element is empty. Starts with i=1. for ( var i = 1 ; i < locations . length ; i ++ ) { result = result + '/' + toTitleCaseTimezoneLocation ( locations [ i ] ) ; } } return result ; }
Returns canonical Area/Location(/Location) name, or throws an exception
if the zone name is invalid IANA name.
Returns canonical Area / Location ( / Location ) name or throws an exception if the zone name is invalid IANA name .