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

typed-time

v7.0.0

Published

Type-safe, semantic time for JavaScript & TypeScript

Readme

⌛ typed-time

npm downloads

NPM


Type-safe, semantic time for JavaScript & TypeScript
Catch timezone, scheduling, and business-time bugs at compile time.


Why typed-time exists

Time bugs are some of the most expensive production bugs:

  • Mixing local time and UTC
  • Billing or SLAs calculated using server time
  • DST breaking scheduled jobs
  • Background workers replaying events with the wrong clock
  • APIs passing timestamps that lose meaning

JavaScript's Date is mutable, ambiguous, and semantically empty.

typed-time fixes this by putting time meaning into the type system.


Installation

npm install typed-time

Core idea

type Time<Kind extends string> = {
  readonly __kind: Kind
  readonly epochMs: number
}

A timestamp with meaning.


Basic usage

import { nowUTC, addMinutes } from "typed-time"

const now = nowUTC()
const later = addMinutes(now, 30)

Time zones (explicit only)

import { nowLocal, localToUTC } from "typed-time"

const local = nowLocal()
const utc = localToUTC(local)

No silent conversions. No guessing.


Business time vs System time

import { BusinessUTC, SystemUTC } from "typed-time"

function billCustomer(at: BusinessUTC) {}

billCustomer({} as SystemUTC)
// ❌ Compile-time error

This prevents billing, SLA, and scheduling bugs.


Serialization & JSON safety

import { serialize, deserialize } from "typed-time"

const payload = serialize(nowUTC())
const time = deserialize<"UTC">(payload)

Safe across APIs, queues, DBs, and workers.


Node.js real-world example

import { BusinessUTC, addMinutes } from "typed-time"

export function scheduleOrder(
  requestedAt: BusinessUTC
): BusinessUTC {
  return addMinutes(requestedAt, 15)
}

Impossible to pass Date, local time, or system time by mistake.


Another example

// Time comparison example

import { TypedTime, format, isBefore, isSameDate, isSameTime, isAfter } from "typed-time";
// Current time
const now = TypedTime.nowUTC();

// Business time example
const meeting = TypedTime.from("2026-01-24T15:17:00Z");

// Formatting
console.log(format(now, "hh:mm a dd/MM/yyyy")); // "03:17 pm 24/01/2026"

// Comparison
console.log(isBefore(now, meeting));           // true
console.log(isSameDate(now, meeting));         // true

// Time-only comparison
const lunchTime = TypedTime.from("2026-01-24T12:30:00Z");
console.log(isSameTime(meeting, lunchTime));   // false

// ===========================================================

// Another example

function testSchedule() {
  const start = TypedTime.from("2026-01-24T09:00:00Z");
  const end = TypedTime.from("2026-01-24T17:00:00Z");
  const now = TypedTime.nowUTC();

  if (isBefore(now, start)) console.log("Workday not started");
  if (isAfter(now, end)) console.log("Workday finished");
  console.log("Current time:", format(now, "hh:mm a dd/MM/yyyy"));
}

testSchedule();

Migration strategy from Date

Step 1: Stop Date at boundaries

function handler(time: UTC) {}
handler(utc(Date.now()))

Step 2: Centralize time creation

export const nowBusiness = () => businessUTC(Date.now())

Step 3: Keep formatting libraries

format(new Date(time.epochMs), "yyyy-MM-dd")

Step 4: Migrate critical paths first

Billing, scheduling, cron, workers.

Step 5: Let TypeScript guide you

Type errors show where time meaning was unclear.


Performance

  • Zero runtime abstractions
  • Plain objects
  • No parsing
  • Cheaper than Date in hot paths

Philosophy

Time is not just a number.
If meaning matters, it belongs in the type system.


License

MIT © Ethern Myth