Socket
Socket
Sign inDemoInstall

@mapbox/timespace

Package Overview
Dependencies
22
Maintainers
163
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mapbox/timespace

compute fuzzy local time from a location


Version published
Weekly downloads
1.8K
decreased by-13.51%
Maintainers
163
Install size
6.58 MB
Created
Weekly downloads
 

Readme

Source

timespace Build Status

Compute fuzzy local time from a location. The default accuracy is zoom level 8. See "Regenerate timezones.json" section for instructions on how to change accuracy.

Timezone data is from https://github.com/evansiroky/timezone-boundary-builder/.

Install

npm install @mapbox/timespace

Test

npm run test

Use

Functions

var ts = require('@mapbox/timespace');

var timestamp = Date.now();
var point = [-122.27783203125, 37.84015683604136];
var time = ts.getFuzzyLocalTimeFromPoint(timestamp, point);
//=> (a `moment-timezone` object – see https://momentjs.com/timezone/)


var tile = [41, 98, 8];     // the tile [x, y, z] whose timezone we want to know
var timezone1 = ts.getFuzzyTimezoneFromTile(tile);
//=> 'America/Los_Angeles'


var quadkey = '02301021';   // the quadkey whose timezone we want to know
var timezone2 = ts.getFuzzyTimezoneFromQuadkey(quadkey);
//=> 'America/Los_Angeles'

./lib/timezones.json file contains the timezone name of every z8 tile that contains land.

If a tile/quadkey with zoom levels > 8 is passed into timespace functions, the timezone of its z8 parent is returned.

If a tile/quadkey with zoom levels < 8 is passed into timespace functions, the most popular timezone amongst its z8 children is returned.

Regenerate timezones.json

To update timezone.json,

  1. find the link address of the latest timezones.shapefile.zip release from https://github.com/evansiroky/timezone-boundary-builder/releases,
  2. replace the link address in this line with the the link from step 1
  3. run npm run regenerate
  4. run npm run test to verify the new timezones.json file is ok

To generate timezone.json for another zoom level:

  1. change the number in this line to the desired zoom level,
  2. run npm run regenerate
  3. run npm run test to verify the new timezones.json file is ok

Keywords

FAQs

Last updated on 07 Sep 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc