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

@fcf-ebisawa/time-delta

v0.1.1

Published

A TypeScript library for precise time duration calculations and manipulations with signed time support

Readme

Time delta

A TypeScript library for time calculations. Provides functionality for calculating time differences, time arithmetic operations, and format conversions.

Features

  • ⚡️ Time difference calculations and operations
  • 🎯 Type safety with TypeScript
  • ✅ Comprehensive test coverage with Vitest
  • 📦 Supports both ES Modules and CommonJS

Installation

npm install @fcf-ebisawa/time-delta

Basic Usage

Calculating Time Differences

import { duration, timeDiff } from '@fcf-ebisawa/time-delta';

// Basic time difference calculation
const diff = duration(new Date('2024-01-01T10:00:00'), new Date('2024-01-01T12:30:00'));
console.log(diff.toString()); // "02:30:00.000"

// Time difference calculation with options
const roundedDiff = timeDiff(new Date('2024-01-01T10:00:00'), new Date('2024-01-01T12:30:45'), {
  roundTo: 'hour',
});
console.log(roundedDiff.toString()); // "03:00:00.000"

Using SignedTime Class

import { SignedTime } from '@fcf-ebisawa/time-delta';

// Creating an instance
const time = new SignedTime(1, 30, 45, 500); // 1 hour 30 minutes 45 seconds 500 milliseconds
console.log(time.toString()); // "01:30:45.500"

// Adding time
const time1 = new SignedTime(1, 30, 0);
const time2 = new SignedTime(0, 45, 0);
const sum = time1.add(time2);
console.log(sum.toString()); // "02:15:00.000"

// Custom format
console.log(time.toString('h hours m minutes s seconds')); // "1 hours 30 minutes 45 seconds"

// Comparing times
const isGreater = time1.isGreaterThan(time2); // true

API Reference

duration(from: DateLike, to: DateLike): SignedTime

Calculates the time difference between two dates.

  • Parameters
    • from: Start date/time (Date, string, or number)
    • to: End date/time (Date, string, or number)
  • Returns: SignedTime instance

timeDiff(from: DateLike, to: DateLike, options?): SignedTime

Calculates the time difference between two dates and processes it based on options.

  • Parameters
    • from: Start date/time
    • to: End date/time
    • options:
      • absolute: If true, converts the result to absolute value
      • roundTo: Rounding unit ('hour' | 'minute' | 'second')
  • Returns: SignedTime instance

SignedTime

A class representing time that provides the following features:

  • Time addition, subtraction, multiplication, and division
  • Time comparison
  • Format conversion
  • Rounding operations
  • Absolute value calculation
  • Sign inversion

For detailed methods and properties, please refer to the JSDoc comments in the source code.

Development

# Install dependencies
npm install

# Run tests
npm test
npm run test:coverage

# Lint and format
npm run lint
npm run lint:fix
npm run format

# Build
npm run build

License

Apache-2.0


[!NOTE] Please report bugs and feature requests through GitHub Issues.