timezone-id

1.0.15 • Public • Published

update: 01.01.2020

If you want to find tz by city name, you need to get the key for geocoder here

Description

timezone client module for node.js that provides an asynchronous interface for getting timezone by city name or coords. zone ID will be retrieved from here:

  1. https://geocode-maps.yandex.ru/1.x/?geocode=[city]&format=json&results=1
  2. https://api.teleport.org/api/locations/[coordinates]/?embed=location:nearest-cities/location:nearest-city/city:timezone

Requirements

  • node.js -- v0.8.0 or newer
  • API_KEY from here -- for city names

Install

npm install timezone-id

Examples

  • Get a timezone by city name:
  var tz = require('timezone-id');
  
  tz.getTimeZone('Sydney', API_KEY).then(timeZoneId => {
        console.log(timeZoneId); //Australia/Sydney
      })
  • Get a timezone by location coordinates:
  var tz = require('timezone-id');
    tz.getTimeZone([55.755814, 37.617635]).then(timeZoneId => {
          console.log(timeZoneId); //Asia/Tehran
        })

Readme

Keywords

Package Sidebar

Install

npm i timezone-id

Weekly Downloads

41

Version

1.0.15

License

ISC

Unpacked Size

10.9 kB

Total Files

10

Last publish

Collaborators

  • albertincx