new TimeZones()
Provides utilities for looking up timezones for locations.
This class uses a detailed lookup table of latitude/longitude values to find the timezone for any location on the Earth's surface. Timezone boundaries are not straightforward and there is no obvious algorithm for accurately determining the timezone for every part of every country. This lookup table is accurate to within 0.5deg in both latitude and longitude, which should be sufficient for most design applications.
Longitude values must be given as Eastings ain degrees. This means that longitudes to the west of the Prime Meridian are negative (America) and those to the east are positive (Europe and Asia).
Latitude values must be given as Northings in degrees. This means that latitudes south of the Equator are negative (Australia and South America) and those to the north are positive (Canada, Europe and Russia).
Example
const lng = -74.0060; const lat = 40.7128; const timezone = PD.TimeZones.lookup(lat, lng);
Methods
-
getIANA() <static>
-
Retrieve a list of world time zones.
Each entry in the list as a
nameandoffsetproperty (in decimal hours), with some also having adstproperty giving daylight savings time periods.This data is maintained by the Internet Assigned Numbers Authority (IANA) for use as a digital standard.
Returns:
Returns an array of IANA timezone data.
- Type
- Array
-
getStandardTimeZones() <static>
-
Retrieves an array of standard time zone offsets.
Each item in the list is an object with a
nameandvalueproperty, where the name is for display and thevalueis in decimal hours.Returns:
Returns an array of standard time zone objects.
- Type
- Array
-
lookup(lat, lng) <static>
-
Searches for the timezone associated with the given location.
Parameters:
Name Type Description latnumber The location latitude in decimal degrees (-90 to 90).
lngnumber The location longitude in decimal degrees (-180 to 180).
Returns:
Returns a timezone offset in decimal hours.
- Type
- number
-
toStandardTimeZone(tz) <static>
-
Converts the given timezone to a standard time zone.
A standard timezone refers to the nearest region of the world with the given UTC time offset.
Parameters:
Name Type Description tznumber The selected timezone in decimal time.
Returns:
Returns the closest standard timezone.
- Type
- number