Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

gps-time

1.0.3 • Public • Published

gps-time.js

Build Status

Small utility to convert times between GPS epoch (midnight January 6, 1980) and Unix epoch (midnight January 1, 1970), taking into account leap seconds.

No dependencies! Very small: 464 bytes gzipped.

Works on the client and on the server (in Node.js).

Node.js installation

npm install gps-time

Usage

AMD and CommonJS are supported, with a fallback that defines this utility at window.gpsTime

In Node, you can bring in this utility with this:

var gpsTime = require('gps-time');

Converting from Unix time to GPS time.

var unixMS = Date.now();  // 1454168480000
gpsTime.toGPSMS(unixMS);  // 1138203697000

Converting from GPS time to Unix time.

var gpsMS = 1138203697000;
gpsTime.toUnixMS(gpsMS);  // 1454168480000

Tests

This comes with a small test suite which can be run like this:

$ npm install --dev
$ npm test

License

Licenced under MIT

install

npm i gps-time

Downloadsweekly downloads

214

version

1.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability