Initialize a Location instance
Latitude as a decimal, valid range -90 thru +90 (e.g. 41.85003)
Longitude as a decimal, valid range -180 thru +180 (e.g. -87.65005)
in Israel (true) or Diaspora (false)
Olson timezone ID, e.g. "America/Chicago"
OptionalcityName: string
optional descriptive city name
OptionalcountryCode: string
ISO 3166 alpha-2 country code (e.g. "FR")
Optionalgeoid: string | number
optional string or numeric geographic ID
Optionalelevation: number
in meters (default 0)
Optionaladmin1First-level administrative division (e.g. a US state or a French
region) as an abbreviation, such as "CA". Not set by this package;
populated by callers that hydrate a Location from a geo database.
OptionalasciinameCity name in plain ASCII, for sorting or URL generation. Not set by this package.
ProtectedelevationOptionalgeoWhich kind of lookup produced this location: 'zip' for a US Zip Code
or 'geoname' for a GeoNames city. Not set by this package.
ProtectedlatitudeProtectedlocationProtectedlongitudeOptionalpopulationApproximate population of the city. Not set by this package.
OptionalstateFull name of the first-level administrative division, such as
"California". Not set by this package.
ProtectedtimeOptionalzipUS Zip Code, such as "02912". Not set by this package.
Adjust the date for antimeridian crossover. This is needed to deal with edge cases such as Samoa that use a different calendar date than expected based on their geographic location.
The actual Time Zone offset may deviate from the expected offset based on the longitude. Since the 'absolute time' calculations are always based on longitudinal offset from UTC for a given date, the date is presumed to only increase East of the Prime Meridian, and to only decrease West of it. For Time Zones that cross the antimeridian, the date will be artificially adjusted before calculation to conform with this presumption.
For example, Apia, Samoa with a longitude of -171.75 uses a local offset of +14:00. When calculating sunrise for 2018-02-03, the calculator should operate using 2018-02-02 since the expected zone is -11. After determining the UTC time, the local DST offset of UTC+14:00 should be applied to bring the date back to 2018-02-03.
the date, at the start of which (in this location's time zone) the offset is read
the number of days to adjust the date This will typically be 0 unless the date crosses the antimeridian
Returns the ISO 3166 alpha-2 country code (e.g. "US", "IL", "FR")
passed to the constructor, or undefined if none was provided.
Method to get the elevation in Meters.
Returns the elevation in Meters.
Returns the optional geographic identifier passed to the constructor
(typically a GeoNames numeric ID or a US Zip Code string), or
undefined if none was provided.
Returns true if this location is in Israel (uses the Israeli holiday
and Torah-reading schedule), false for the Diaspora.
Returns the latitude.
A method that will return the location's local mean time offset in milliseconds from local standard time. The globe is split into 360°, with 15° per hour of the day. For a local that is at a longitude that is evenly divisible by 15 (longitude % 15 == 0), at solar noon (with adjustment for the equation of time) the sun should be directly overhead, so a user who is 1° west of this will have noon at 4 minutes after standard time noon, and conversely, a user who is 1° east of the 15° longitude will have noon at 11:56 AM.
the instant at which to read the time zone offset (DST is taken into account)
the offset in milliseconds not accounting for Daylight saving time. A positive value will be returned East of the 15° timezone line, and a negative value West of it.
Returns the location name.
Returns the longitude.
Returns the full descriptive location name passed to the constructor,
or null if no name was provided.
Note that the built-in classic cities are named by city alone, so
getName() and getShortName return the same string for them.
Returns the location name truncated at the first comma. Useful for compact display where only the city name is desired.
Special-cased so that US locations of the form "Washington, DC ..." or
"Washington, D.C., ..." keep the DC / D.C. suffix attached.
Returns a cached 24-hour Intl.DateTimeFormat (e.g. 07:41 or 20:03)
configured for this location's timezone. Formatters are memoized by
timezone so repeated calls do not allocate.
Returns the timeZone.
Returns the Olson timezone identifier (e.g. "America/Chicago").
Alias for getTimeZone() from the parent GeoLocation class.
Method to set the elevation in Meters above sea level.
The elevation to set in Meters. An Error will be thrown if the value is a negative.
The setter method for the display name.
Method to set the TimeZone.
The timeZone to set.
Returns a JSON-serialized representation of this Location. Useful for debugging and structured logging.
StaticaddRegisters a new named location with the built-in Location.lookup()
registry. Names are stored case-insensitively. Returns false if a
location with the same (lower-cased) name is already registered, and
true if successfully added.
Use this to extend the built-in set of 65 classic Hebcal cities with your own custom locations.
name to register the location under (case insensitive)
the Location instance to register
StaticgetConverts timezone info from Zip-Codes.com to a standard Olson tzid.
two-letter all-caps US state abbreviation like 'CA'
positive number, 5=America/New_York, 8=America/Los_Angeles
single char 'Y' or 'N'
StaticlegacyConverts a legacy Hebcal-style timezone (a numeric GMT offset plus a coarse DST region) to a standard IANA/Olson timezone ID.
This exists to migrate data from older Hebcal versions that stored timezones as GMT offset + DST scheme rather than as a full tzid.
integer, GMT offset in hours
'none', 'eu', 'usa', or 'israel'
StaticlookupCreates a location object from one of 65 "classic" Hebcal city names. The following city names are supported: 'Ashdod', 'Atlanta', 'Austin', 'Baghdad', 'Beer Sheva', 'Berlin', 'Baltimore', 'Bogota', 'Boston', 'Budapest', 'Buenos Aires', 'Buffalo', 'Chicago', 'Cincinnati', 'Cleveland', 'Dallas', 'Denver', 'Detroit', 'Eilat', 'Gibraltar', 'Haifa', 'Hawaii', 'Helsinki', 'Houston', 'Jerusalem', 'Johannesburg', 'Kiev', 'La Paz', 'Livingston', 'Las Vegas', 'London', 'Los Angeles', 'Marseilles', 'Miami', 'Minneapolis', 'Melbourne', 'Mexico City', 'Montreal', 'Moscow', 'New York', 'Omaha', 'Ottawa', 'Panama City', 'Paris', 'Pawtucket', 'Petach Tikvah', 'Philadelphia', 'Phoenix', 'Pittsburgh', 'Providence', 'Portland', 'Saint Louis', 'Saint Petersburg', 'San Diego', 'San Francisco', 'Sao Paulo', 'Seattle', 'Sydney', 'Tel Aviv', 'Tiberias', 'Toronto', 'Vancouver', 'White Plains', 'Washington DC', 'Worcester'
Lookups are case-insensitive. Returns undefined if the name is not
recognized. The list can be extended with Location.addLocation.
case-insensitive classic city name
Class representing a geographic location for use with candle-lighting, havdalah, and zmanim calculations.
Extends GeoLocation from
@hebcal/noaawith Jewish-calendar specific data: an Israel/Diaspora flag, ISO country code, and an optional geographic identifier. Also provides Location.lookup for the 65 built-in "classic" Hebcal cities.Example