• Stars
    star
    105
  • Rank 328,196 (Top 7 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 12 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Determine timezone from lat/long in NodeJS

tzwhere Build Status

Determine timezone from lat/long in NodeJS

PROBABLY DON'T USE THIS IN NEW PROJECTS

It probably still works! But, timezone boundaries actually change over time, and this hasn't been updated in a while. Also, bugs are discovered over time, and in this particular library, they're not fixed anymore! New language features are added over time, and this library makes no attempt to take advantage of them! Until somebody puts in the time to polish this up I would recommend you don't start a new project using it. Here's a library that looks like it does the same thing but has an active maintainer:

https://github.com/evansiroky/node-geo-tz https://www.npmjs.com/package/geo-tz

CALL FOR MAINTAINERS

I am no longer actively working on this project and review PRs about once every three or four months. If you believe you'd be a good maintainer of this project, please get in touch.

Installation

Installing tzwhere

npm install tzwhere

Example Usage

var tzwhere = require('tzwhere')
tzwhere.init();

var whiteHouse = {'lat': 38.897663, 'lng': -77.036562};

// Determine the timezone of the White House
console.log(tzwhere.tzNameAt(whiteHouse['lat'], whiteHouse['lng']));

// Determine the current offset from UTC, in milliseconds, of the White House's timezone
console.log(tzwhere.tzOffsetAt(whiteHouse['lat'], whiteHouse['lng']));

yields:

America/New_York
-14400000

or

America/New_York
-18000000

depending on the current state of daylight savings time in the America/New_York timezone. You can also do it asynchronously.

...
tzwhere.tzNameAt(whiteHouse['lat'], whiteHouse['lng'], function (error, result) {
	if (error) {
		console.log(error);
	} else {
		console.log(result);
	}
}
...

You can also pass alternative GeoJSON shape files:

var tzwhere = require('tzwhere')
tzwhere.init('path/to/alternative/tz/file');

...

Check the tests for more comprehensive usage, including determining the timezone offsets at arbitrary dates (very useful for scheduling future events expressed in local time).

License

tzwhere is free software, and is distributed under the terms of the MIT license (see LICENSE.txt).

More Repositories

1

libphonenumber

NodeJS port of Google's libphonenumber (thanks to SocialCam), packaged for npm
JavaScript
63
star
2

Arduino-Watchdog-Circuit

The current Arduino library has bugs in the freelist implementation, which can lead to difficult to debug system hangs. For maximum reliability of my home automation projects, I built an external hardware watchdog.
Arduino
32
star
3

Hive-Demo

Following along with the Hive tutorial at StrataConf / HadoopWorld
Java
22
star
4

Arduino-GCal-Relays

Control relays on a schedule by polling Google Calendar
Arduino
11
star
5

python-oozie-client

Talk to the Oozie web API
Python
10
star
6

beerbug

Monitoring ambient conditions for homebrew
Python
9
star
7

node-leak-patterns

JavaScript
7
star
8

spice

A Python package which provides access to the NASA NAIF SPICE toolkit
C
6
star
9

cdf

A Python package which handles files in NASA Common Data Format
C
5
star
10

node-angelsensor

Node.js library for Angel sensor band
JavaScript
3
star
11

Hadoop-SplitOutputFormat

Split TextOutputFormat files by capping the number of bytes each file may contain.
Java
2
star
12

python-growl-recipe

A demonstration of how to install a Python app which creates Growl notifications
Python
2
star
13

Roku-Bootstrap

Getting started on a Roku channel
Python
2
star
14

PigJSONSchemas

Puzzling out how to describe JSON structure to the Pig 0.10.0 built-in JSONLoader
Shell
2
star
15

NeedMorseCowbell

For when your life needs morse code
Python
1
star
16

Particle-Soundtouch-Control

Particle.io library for Bose Soundtouch system control
C++
1
star
17

cardinality-mongo-persistence

Mongo database persistence for NodeJS cardinality estimation
JavaScript
1
star
18

Lambda-Bootstrap

My first AWS Lambda functions, and how to do it yourself
Shell
1
star
19

SmartTV-X10-Widget

Create a Yahoo! Connected TV widget which interfaces with the my Arduino X10 controller
JavaScript
1
star
20

HadoopDemo

Test drive Hadoop on Amazon EC2
Ruby
1
star
21

diffval

Validates tests by comparing real output against expected output
Python
1
star
22

mattbornski.github.com

GitHub Pages
1
star
23

Arduino-Clipper-Recognition

Recognize your Clipper card, and then do something.
C++
1
star
24

Android-Arduino-X10

C++
1
star
25

shmac

Mac-specific shell helpers
Python
1
star
26

315MHz-Testing

Testing range and power of 315 MHz transmission
1
star
27

Arduino-MemoryLeaks

Library to inventory available RAM, and a demo sketch which leaks.
Arduino
1
star
28

techshop

TechShop projects
1
star
29

raplets

Raplets to add value to GMail, including one to query World Adult Kickball Association (WAKA) website for player history and current team registration.
Python
1
star
30

Android-Wake-Service

Android service which parses "next alarm time" and interfaces with Arduino X10 controller to turn on lights in anticipation
Java
1
star