Return the canonical country code for this tzid.  If we have none, or if the time zone
is not associated with a country or unknown, return null. When the given zone is the
primary zone of the country, true is set to isPrimary.
970436
public static String getCanonicalCountry(String tzid, Output<Boolean> isPrimary) {
        isPrimary.value = Boolean.FALSE;

        String country = getRegion(tzid);
        if (country != null && country.equals(kWorld)) {
            return null;
        }

        // Check the cache
        Boolean singleZone = SINGLE_COUNTRY_CACHE.get(tzid);
        if (singleZone == null) {
            Set<String> ids = TimeZone.getAvailableIDs(SystemTimeZoneType.CANONICAL_LOCATION, country, null);
            assert(ids.size() >= 1);
            singleZone = Boolean.valueOf(ids.size() <= 1);
            SINGLE_COUNTRY_CACHE.put(tzid, singleZone);
        }

        if (singleZone) {
            isPrimary.value = Boolean.TRUE;
        } else {
            // Note: We may cache the primary zone map in future.

            // Even a country has multiple zones, one of them might be
            // dominant and treated as a primary zone.
            try {
                UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "metaZones");
                UResourceBundle primaryZones = bundle.get("primaryZones");
                String primaryZone = primaryZones.getString(country);
                if (tzid.equals(primaryZone)) {
                    isPrimary.value = Boolean.TRUE;
                } else {
                    // The given ID might not be a canonical ID
                    String canonicalID = getCanonicalCLDRID(tzid);
                    if (canonicalID != null && canonicalID.equals(primaryZone)) {
                        isPrimary.value = Boolean.TRUE;
                    }
                }
            } catch (MissingResourceException e) {
                // ignore
            }
        }

        return country;
    }
63584
public static SimpleTimeZone getCustomTimeZone(int offset) {
        boolean negative = false;
        int tmp = offset;
        if (offset < 0) {
            negative = true;
            tmp = -offset;
        }

        int hour, min, sec;

        if (ASSERT) {
            Assert.assrt("millis!=0", tmp % 1000 != 0);
        }
        tmp /= 1000;
        sec = tmp % 60;
        tmp /= 60;
        min = tmp % 60;
        hour = tmp / 60;

        // Note: No millisecond part included in TZID for now
        String zid = formatCustomID(hour, min, sec, negative);

        return new SimpleTimeZone(offset, zid);
    }
524388
public static TimeZone toTimeZone(ZoneId zoneId) {
        String tzid = zoneId.getId();
        if (tzid.startsWith("+") || tzid.startsWith("-")) {
            tzid = "GMT" + tzid;
        } else if (tzid.equals("Z")) {
            tzid = "UTC";
        }
        return TimeZone.getTimeZone(tzid);
    }
700201
function getZone(zone) {
        if (!zone) return "main";
        if (zone.length == 1) {
            zone = zone.replace("/^1", "main");
            zone = zone.replace("/^2", "zone2");
            zone = zone.replace("/^3", "zone3");
            zone = zone.replace("/^4", "zone4");
        }
        switch (zone) {
            case 1:
                zone = "main";
                break;
            case 2: case 3: case 4:
                zone = "zone" + zone;
        }
        return zone;
    }
1092000
def getCountry(self, default=None):
        
        physical_address = self.getPhysicalAddress().get("country", default)
        postal_address = self.getPostalAddress().get("country", default)
        return physical_address or postal_address
960721
def zmanim(self):
        """"""
        return {key: self.utc_minute_timezone(value) for
                key, value in self.get_utc_sun_time_full().items()}
1130616
protected function validateZoneCountryState()
    {
        $field = 'zone_id';
        $value = $this->getSubmitted($field);

        if (empty($value)) {
            return null;
        }

        $label = $this->translation->text('Zone');

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        $zone = $this->zone->get($value);

        if (empty($zone)) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        return true;
    }
1254929
def countries(instance):
    
    if (instance['type'] == 'location' and 'country' in instance and not
            instance['country'].upper() in enums.COUNTRY_CODES):

        return JSONError("Location `country` should be a valid ISO 3166-1 "
                         "ALPHA-2 Code.",
                         instance['id'], 'marking-definition-type')
563980
def tz(self):
        """"""

        if self.timezone is None:
            return None

        try:
            tz = pytz.timezone(self.timezone)
            return tz
        except pytz.UnknownTimeZoneError:
            raise AstralError("Unknown timezone '%s'" % self.timezone)
321891
public static String getShortID(TimeZone tz) {
        String canonicalID = null;

        if (tz instanceof OlsonTimeZone) {
            canonicalID = ((OlsonTimeZone)tz).getCanonicalID();
        }
        else {
            canonicalID = getCanonicalCLDRID(tz.getID());
        }
        if (canonicalID == null) {
            return null;
        }
        return getShortIDFromCanonical(canonicalID);
    }
623535
def _region_code_for_short_number_from_region_list(numobj, region_codes):
    
    if len(region_codes) == 0:
        return None
    elif len(region_codes) == 1:
        return region_codes[0]
    national_number = national_significant_number(numobj)
    for region_code in region_codes:
        metadata = PhoneMetadata.short_metadata_for_region(region_code)
        if metadata is not None and _matches_possible_number_and_national_number(national_number, metadata.short_code):
            # The number is valid for this region.
            return region_code
    return None
809783
private static Timezone getTimezone(
        ChronoEntity<?> entity,
        AttributeQuery attrs
    ) {

        TZID tzid = null;

        if (entity.hasTimezone()) {
            tzid = entity.getTimezone();
        } else if (attrs.contains(Attributes.TIMEZONE_ID)) {
            tzid = attrs.get(Attributes.TIMEZONE_ID); // Ersatzwert
        }

        if (tzid != null) {
            if (entity.contains(FlagElement.DAYLIGHT_SAVING)) {
                boolean dst = entity.get(FlagElement.DAYLIGHT_SAVING).booleanValue();
                TransitionStrategy strategy =
                    attrs
                        .get(Attributes.TRANSITION_STRATEGY, Timezone.DEFAULT_CONFLICT_STRATEGY)
                        .using(dst ? OverlapResolver.EARLIER_OFFSET : OverlapResolver.LATER_OFFSET);
                return Timezone.of(tzid).with(strategy);
            } else if (attrs.contains(Attributes.TRANSITION_STRATEGY)) {
                return Timezone.of(tzid).with(attrs.get(Attributes.TRANSITION_STRATEGY));
            } else {
                return Timezone.of(tzid);
            }
        }

        throw new AssertionError(
            "Timezone must exist if a moment was successfully parsed.");

    }
445343
private String formatExemplarLocation(TimeZone tz) {
        String location = getTimeZoneNames().getExemplarLocationName(ZoneMeta.getCanonicalCLDRID(tz));
        if (location == null) {
            // Use "unknown" location
            location = getTimeZoneNames().getExemplarLocationName(UNKNOWN_ZONE_ID);
            if (location == null) {
                // last resort
                location = UNKNOWN_LOCATION;
            }
        }
        return location;
    }
380951
@Override
    public String getMetaZoneID(String tzID, long date) {
        return TimeZoneNamesImpl._getMetaZoneID(tzID, date);
    }
1266701
@Nullable
  public static IBANCountryData getCountryData (@Nonnull final String sCountryCode)
  {
    ValueEnforcer.notNull (sCountryCode, "CountryCode");

    return s_aIBANData.get (sCountryCode.toUpperCase (Locale.US));
  }
770158
def native(self):
        

        if self.contents is None:
            return None

        if self._native is None:
            string = str_cls(self)
            has_timezone = re.search('[-\\+]', string)

            # We don't know what timezone it is in, or it is UTC because of a Z
            # suffix, so we just assume UTC
            if not has_timezone:
                string = string.rstrip('Z')
                date = self._date_by_len(string)
                self._native = date.replace(tzinfo=timezone.utc)

            else:
                # Python 2 doesn't support the %z format code, so we have to manually
                # process the timezone offset.
                date = self._date_by_len(string[0:-5])

                hours = int(string[-4:-2])
                minutes = int(string[-2:])
                delta = timedelta(hours=abs(hours), minutes=minutes)
                if hours < 0:
                    date -= delta
                else:
                    date += delta

                self._native = date.replace(tzinfo=timezone.utc)

        return self._native
455607
private String getHemisphereFromZone(final String zone) {

		String band = null;

		switch (zone.length()) {

			case 3:
				// we can safely assume a format of "32U"
				band = zone.substring(2);
				break;

			case 2:
				// can be either single digit zone plus band
				// or double digit zone w/o band..
				if (zone.matches("\\d\\D")) {

					// single-digit zone plus band
					band = zone.substring(1);
				}
				break;
		}

		if (band != null) {

			final int pos = UTMzdlChars.indexOf(band);
			if (pos >= 0) {

				return UTMHemisphere.substring(pos, pos+1);
			}
		}

		logger.warn("Unable to determine hemisphere from UTM zone, assuming NORTHERN hemisphere.");

		return "N";
	}