byProximity method
Provides a list of time zones sorted by proximity to a given set of geographic coordinates. Optionally filters by country.
The proximity sort is deliberately biased towards locations on similar longitudes since time zones tend to be much narrower in the east-west direction.
The country
arg is an ISO 3166 2-letter
code.
For example, US = United States, CA = Canada, EE = Estonia, etc.
Implementation
List<ZoneDescription> byProximity(double latitude, double longitude,
[String? country]) {
var zones = descriptions.toList();
if (country != null) {
zones = descriptionsByCountry[country].toList();
}
zones.sortByCompare((x) => x, _compareByProximityTo(latitude, longitude));
return zones;
}