getTimeZonesForNumber method
As per getTimeZonesForGeographicalNumber(PhoneNumber) but explicitly checks the validity of the number passed in.
number
the phone number for which we want to get the time zones to
which it belongs.
returns a list of the corresponding time zones or a single element list with
the default unknown time zone if no other time zone was found or if the number
was invalid
Implementation
List<String> getTimeZonesForNumber(PhoneNumber number) {
PhoneNumberUtil util = PhoneNumberUtil.instance;
PhoneNumberType numberType = util.getNumberType(number);
if (numberType == PhoneNumberType.unknown) {
return unknownTimeZoneList;
} else if (!util.isNumberGeographical(
phoneNumberType: numberType, countryCallingCode: number.countryCode)) {
return _getCountryLevelTimeZonesforNumber(number);
}
return getTimeZonesForGeographicalNumber(number);
}