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 🙏

© 2026 – Pkg Stats / Ryan Hefner

the-time

v1.0.1

Published

JavaScript time data struct

Readme

The-Time Library

The-Time is a simple JavaScript library for time manipulation and comparison. It provides a flexible, easy-to-use interface for working with time.

Branches Functions Lines Statements Jest coverage

Features

  • Create Time instances from time string.
  • Get hours, minutes, and seconds from Time instances.
  • Add and subtract hours, minutes, and seconds from Time instances.
  • Compare Time instances.
  • Convert Time instances to string format.
  • Handle overflow time operations.

Installation

Use npm to install The-Time library:

npm install the-time

Usage

Here is a basic usage of the The-Time library:

import { Time } from 'the-time';

let options = { overflow: true };
let time = new Time('23:45:50', options);
console.log(time.toString()); // outputs: 23:45:50.000

time.add(20, 'minutes');
console.log(time.toString()); // outputs: 00:05:50.000 (because of overflow option)

let time2 = new Time('00:00:00');
console.log(time.isGreaterThan(time2)); // outputs: true

API Reference

class Time

constructor(timeString: string, options: ITimeOptions = {})

Creates a new Time instance from a time string. timeString must be in the format 'HH:mm:ss'. If options.overflow is set to true (which is the default), time will overflow when adding or subtracting (23:59:59 + 1 minute = 00:00:59).
options.utcOffset can be used to set the UTC offset of the time string.

toString(): string

Returns the string representation of the Time instance in the format 'HH:mm:ss.fff'.

toTimeString(): string

Returns the string representation of the Time instance in the format 'HH:mm:ss'.

getHours(): number

Returns the hour component of the Time instance.

getMinutes(): number

Returns the minute component of the Time instance.

getSeconds(): number

Returns the second component of the Time instance.

add(amount: number, d: TTimeValue): ITime

Adds the specified amount of hours, minutes, or seconds to the Time instance. Returns the Time instance for chaining.

subtract(amount: number, d: TTimeValue): ITime

Subtracts the specified amount of hours, minutes, or seconds from the Time instance. Returns the Time instance for chaining.

isGreaterThan(value: ITime): boolean

Returns true if the Time instance is greater than the provided value.

isLessThan(value: ITime): boolean

Returns true if the Time instance is less than the provided value.

isEqualTo(value: ITime): boolean

Returns true if the Time instance is equal to the provided value.

toSeconds(): number

Returns the total number of seconds in the Time instance.

toDate(): number

Returns the Time instance as a Date instance.

static now(options: ITimeOptions = {}): ITime

Returns the current time as a Time instance.

static isValid(timeString: string): boolean

Checks if a time string is valid.

static fromDate(date: Date, options: ITimeOptions = {}): Time

Creates a new Time instance from a Date instance.

License

MIT