Skip to content
An asynchronous client library for TimeZoneDB API.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.editorconfig
.gitattributes
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
index.js
package.json

README.md

timezonedb-node Logo

An asynchronous client library for TimeZoneDB API.

NPM Package Version NPM Package License NPM Package Downloads devDependencies Status

Node Version Travis CI Build Status Code Climate Status Code Climate Test Coverage Status Inch CI Documentation Coverage Status

NPM Package Statistics

Installation

npm install timezonedb-node

Quick Start

The quickest way to get started is by executing following code:

var timezonedb = require('timezonedb-node')('YOUR_API_KEY');

timezonedb.getTimeZoneData({
    zone: 'Australia/Melbourne'
}, function (error, data) {
    if (!error) {
        console.log(data);
    } else {
        console.error(error);
    }
});

If everything went well, you'll see something like this in your console:

{ 
    status: 'OK',
    message: '',
    countryCode: 'AU',
    zoneName: 'Australia/Melbourne',
    abbreviation: 'AEST',
    gmtOffset: '36000',
    dst: '0',
    timestamp: 1438547603
}

Documentation

getTimeZoneDB

Requests timezone data.

Options

  • zone(default: none, required: true) - Zone name of an area.
  • lat(default: none, required: true if zone not specified) - Latitude of a city.
  • lng(default: none, required: true if zone not specified) - Longitude of a city.
  • time(default: Current Unix timestamp, required: false) - Unix time.

Examples

Requests timezone data of zone.

timezonedb.getTimeZoneData({
    zone: 'Australia/Melbourne'
}, function (error, data) {
    if (!error) {
        console.log(data);
    } else {
        console.error(error);
    }
});

Requests timezone data of location.

timezonedb.getTimeZoneData({
    lat: 53.7833,
    lng: -1.75
}, function (error, data) {
    if (!error) {
        console.log(data);
    } else {
        console.error(error);
    }
});

Requests timezone data of location with manually set time.

timezonedb.getTimeZoneData({
    lat: 53.7833,
    lng: -1.75,
    time: 1366552200
}, function (error, data) {
    if (!error) {
        console.log(data);
    } else {
        console.error(error);
    }
});

Errors

When errors occur, you receive an error object with default properties as a first argument of the callback.

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

License

Distributed under the MIT License.

You can’t perform that action at this time.