canadian-city-timezones
v2.0.0
Published
Searchable timezones for all Canadian cities, towns, townships, villages, hamlets, and municipalities.
Downloads
173
Maintainers
Readme
Usage
npm install canadian-city-timezones
import {find} from 'canadian-city-timezones';
const result = await find((city, province) => city === 'Lethbridge' && province === 'Alberta');
result.city // Lethbridge
result.province // Alberta
result.timezone // America/Edmonton
API
Methods
find(predicate: (value: TimezoneResult) => boolean): Promise<TimezoneResult | null>
Returns the first matching result for the given predicate.
filter(predicate: (value: TimezoneResult) => boolean): AsyncGenerator<TimezoneResult>
Yields all matching results for the given predicate.
values(): AsyncGenerator<TimezoneResult>
Yields all values.
Interfaces
TimezoneResult
{
city: string;
province: string;
timezone: string;
}
Development
Timezones are generated automatically by pulling the list of areas from gc.ca
and feeding them into mapbox.com
to get their coordinates, then getting the timezone using geo-tz
.