1.0.7 • Published 10 years ago
timezonedb-node v1.0.7

An asynchronous client library for TimeZoneDB API.
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:trueifzonenot specified) - Latitude of a city.lng(default:none, required:trueifzonenot 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 testLicense
Distributed under the MIT License.
