Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

windycom/fast-timezone

Repository files navigation

DEPRECATED

Since November 2018 Evan Siroky's geo-tz supports preCache method. Therefore, this package is no longer maintained.

fast-timezone

Timezone lookup service.

About

This is modified version of Evan Siroky's amazing geo-tz, but optimized for speed without any compromises.

The approach here is brutally simple: Load everything into memory. Doing so, fast-timezone will typically consume around 900MB memory extra. Don't even think about using it if you can't spare at least 1GB of extra memory per process.

Installation

npm i fast-timezone

Usage

const getTimezone = require('fast-timezone');
// It is a good idea to wait until the data is loaded. If any lookups are
// performed before that, an error will be thrown.
await getTimezone.loaded;
// Get a time zone by location:
const zone = getTimezone(50.047, 14.435);

Optionally, you can supply a timestamp as the third argument, and you will get the time zone at that time.

In case a time zone is found (which is the case if the arguments are valid), an object is returned:

{
 "id": "Europe/Prague",
 "name": "CEST",
 "offset": 120,
 "designator": "+02:00",
 "type": "t"
}

For a nautical time zone the result looks like:

{
 "id": "Etc/GMT+3",
 "name": "-03",
 "offset": -180,
 "designator": "-03:00",
 "type": "n"
}

where offset is the offset in minutes at the moment of the query, and designator is the zone designator according to ISO 8601.

Also note, the type is n for nautical time zones.

License

This software is licenced under the MIT license.

About

Fast timezone lookup service.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /