1.0.9 • Published 1 year ago

gps-time v1.0.9

Weekly downloads
347
License
MIT
Repository
github
Last release
1 year ago

gps-time.js

Build Status Downloads

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

It's not such a trivial matter as adding a constant number of leap seconds to all time inputs! For any two times, a different number of leap seconds may have elapsed between them. This utility helps figure out exactly how many have elapsed.

No dependencies! Very small: 464 bytes gzipped.

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

Node.js installation

npm i --save 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

1.0.9

1 year ago

1.0.8

3 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago