npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jk21/time-converter

v2.0.0

Published

A library to easily convert unix time, utc and gnss time into one another.

Downloads

22

Readme

time-converter

Time Formats

When working with satellite navigation systems different representations of time need to be converted into one another. Most of the conversions need to be done between the three following representations.

Coordinated Universal Time

The Coordinated Universal Time (UTC) is the primary time standard globally used to regulate clocks and time. It establishes a reference for the current time, forming the basis for civil time and time zones.

Global Satellite Navigation System Time

The Global Satellite Navigation System (GNSS) time is represented in weeks and seconds of the week, also known as time of week, since the launch of the first operable GPS satellite constellation on te 5th of January 1980. At that time the GNSS time was in sync with the Coordinated Universal Time (UTC). Over time up to 18 leap seconds have been added to UTC to accommodate the difference between precise time (International Atomic Time (TAI), as measured by atomic clocks) and imprecise observed solar time.

Unix Time

The Unix time is represented by the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch. The Unix time of the GNSS initial epoch is therefore 315964800.

How to use the library

Installation:

npm i @jk21/time-converter

Usage:

import { TimeConverter } from '@jk21/time-converter';

const timeConverter = new TimeConverter();

Methods:

The gnss-time-converter provides methods to convert one time format into the other two at once or just into one specific. Methods that convert into several time formats return a TimeConversionResult.

interface TimeConversionResult {
    utc: Date;
    leapYear: boolean;
    gnssTime: GnssTime | undefined;
    unixTime: number | undefined;
    leapSeconds: number | undefined;
    nextLeapYear: number | undefined;
}

with Date being the built-in javascript Date object and GnssTime being

interface GnssTime {
  week: number;
  timeOfWeek: number;
}

If the time to be converted is before the initial Unix or GNSS epoch undefined is returned for this time format.

convertUnixTime(unixTime: number): TimeConversionResult
convertGnssTime(gnssTime: GnssTime): TimeConversionResult
convertUtc(utc: Date): TimeConversionResult

Single time conversion methods just return the time format of the converted time.

convertUnixToGnssTime(unixTime: number): GnssTime | undefined
convertUnixToUtc(unixTime: number): Date
convertUtcToGnssTime(utc: Date): GnssTime | undefined
convertUtcToUnixTime(utc: Date): number | undefined
convertGnssToUnixTime(gnssTime: GnssTime): number
convertGnssToUtc(gnssTime: GnssTime): Date