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.
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.
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