Skip to content

timezone functions using a geojson file with global timezones

Notifications You must be signed in to change notification settings

codeforeurope/tz-geo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tz-geo

npm version Build Status Dependency Status Test Coverage

Install

npm install tz-geo

Usage

    var tzgeo = require('tz-geo')
    var name         = tzgeo.tz(47.650499, -122.350070)                                // 'America/Los_Angeles'
    var now          = tzgeo.tzMoment(47.650499, -122.350070)                          // moment-timezone obj
    var specificTime = tzgeo.tzMoment(47.650499, -122.350070, '2016-03-30T01:23:45Z')  // moment-timezone obj

    //Returns an error or timezone string via callback
    tzgeo.getTimezone({ type: 'Point', coordinates: [51.48513770164579, 5.232168700000033 ] }, function(err, result){
      if (err) throw err;
      console.log(result.name);
    });

    //Returns an error or moment-timezone via callback
    tzgeo.getMoment({ type: 'Point', coordinates: [51.48513770164579, 5.232168700000033 ] }, function(err, result){
      if (err) throw err;
      console.log(result.name);
    });

API Docs:

.tz(lat, lon)

Returns timezone name found at lat, lon. Returns null if timezone could not be found at coordinate.

.tzMoment(lat, lon, [dateTime])

Returns a moment-timezone object found at lat, lon. Returns null if timezone could not be found at coordinate. If dateTime is omitted, the moment-timezone will have the current time set. If dateTime is provided, moment-timezone will be set to the time provided according to the timezone found. dateTime can be any single-argument parameter that will get passed to the moment() parser.

.getTimezone(point, callback)

Returns a timezone string found at {type: 'point', coordinates: [lon, lat]}. Returns err if timezone could not be found or no moment-timezone could be constructed from the geojson. If no moment-timezone can be constructed, please let us know so we can add it to our datafile.

.getMoment(point, callback)

Returns a moment-timezone object found at {type: 'point', coordinates: [lon, lat]}. Returns err if timezone could not be found or no moment-timezone could be constructed from the geojson. If no moment-timezone can be constructed, please let us know so wee can add it to our datafile.

About

timezone functions using a geojson file with global timezones

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published