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 🙏

© 2025 – Pkg Stats / Ryan Hefner

waktos

v3.0.1

Published

~5kb for the death of ugly dates!

Readme

Waktos ⏰

npm version TypeScript License: MIT Downloads

~5kb for the death of ugly dates!

Waktos is a lightweight, immutable date manipulation library for JavaScript and TypeScript. Unlike native Date which is bound to the system's local time, Waktos instances carry their own Timezone and Locale context, ensuring consistent behavior across all operations.

  • 🪶 Lightweight — Only ~5kb minified + gzipped
  • 🌍 Context Aware — Operations respect the instance's specific Timezone & Locale
  • 🧩 Modular — Tree-shakeable plugin architecture
  • Fast — Optimized performance with smart caching
  • 🛡️ Safe — Immutable instances and first-class TypeScript support
  • 🎯 Simple — Intuitive, chainable API that just works

Quick Start ☕

npm i waktos
import waktos from 'waktos';

// Current time in your system's timezone
const now = waktos();

// Explicitly set timezone and locale
const date = waktos('2005-04-26', {
  timezone: 'Asia/Jakarta',
  locale: 'id-ID',
});

console.log(date.format('PPPP')); // "Selasa, 26 April 2005"

Why Waktos? 🌐

Timezone & Locale Aware Architecture

Every Waktos instance "remembers" its configuration. Operations like startOf, endOf, or add calculate results based on the instance's timezone, not the server's or browser's local time.

const timestamp = 1715000000000; // A specific moment in UTC

const ny = waktos(timestamp, { timezone: 'America/New_York' });
const tokyo = waktos(timestamp, { timezone: 'Asia/Tokyo' });

// Same moment, but different "start of day" depending on the timezone
console.log(ny.startOf('day').format()); // 2024-05-06T00:00:00-04:00
console.log(tokyo.startOf('day').format()); // 2024-05-06T00:00:00+09:00

// Formatting automatically uses the instance's locale
const fr = waktos(timestamp, { locale: 'fr-FR' });
console.log(fr.format('MMMM')); // "mai"

Core Features 🚀

Parsing & Creation

Waktos handles various input formats consistently.

// Current time
waktos();

// Parse ISO string
waktos('2023-05-19T01:02:03+07:00');

// Parse local date (Midnight in the specified/local timezone)
const birthday = waktos('2005-04-26');

// Parse UTC date (Midnight UTC)
const utcBirthday = waktos.utc('2005-04-26');

Intuitive Arithmetic

Perform date math without mutating the original instance.

const date = waktos('2005-04-26');

const nextWeek = date.add(7, 'day');
const twoMonthsAgo = date.sub(2, 'month');
const startOfWeek = date.startOf('week'); // Respects locale's first day of week
const endOfMonth = date.endOf('month');

Plugins 🔌

Waktos is extensible by design. Import only what you need.

import waktos from 'waktos';
import businessTime from 'waktos/plugin/businessTime';

waktos.plugin(businessTime);

const date = waktos('2005-04-26');
console.log(date.isWeekday()); // true
console.log(date.quarterOfYear()); // 2

Formatting ✨

Format dates using standard tokens. Waktos leverages Intl.DateTimeFormat for accurate localization.

const date = waktos('2005-04-26');

// Localized Presets
date.format('P'); // "04/26/05"
date.format('PP'); // "Apr 26, 2005"
date.format('PPP'); // "April 26, 2005"
date.format('PPPP'); // "Tuesday, April 26, 2005"

// Custom Patterns
date.format('YYYY-MM-DD'); // "2005-04-26"
date.format('[Born on] dddd'); // "Born on Tuesday"
date.format('h:mm A Z'); // "12:00 AM +07:00"

TypeScript Support 💙

Waktos is written in TypeScript and provides types out of the box.

import { type DateInput, type Waktos, waktos } from 'waktos';

const scheduleMeeting = (date: DateInput, duration: number): Waktos => {
  return waktos(date).add(duration, 'minute');
};

Environment Support 🌐

  • Node.js: 18+ (ESM & CommonJS)
  • Browsers: Modern browsers (Chrome 85+, Firefox 79+, Safari 14+, Edge 85+)
  • Mobile: iOS 14.7+, Android 85+

[!NOTE] For legacy environments, ensure appropriate polyfills are available.

Migration Guide 📦

From Day.js

Migration is straightforward as Waktos shares a similar API philosophy.

-dayjs('2005-04-26').add(1, 'second');
+waktos('2005-04-26').add(1, 'second');
  • Differences: Units are singular (e.g., 'day', not 'days') for consistency.

From Native Date

Stop wrestling with mutable state and inconsistent parsing.

-const date = new Date('2005-04-26');
-date.setDate(date.getDate() + 99); // Mutates original date!
+waktos('2005-04-26').add(99, 'day'); // Returns new instance

FAQ 🤔

Q: Why another date library? A: To provide a modern, immutable, and lightweight alternative that explicitly handles Timezone and Locale context in every operation, fixing the common pitfalls of the native Date object.

Q: How does it impact bundle size? A: Minimally. Waktos is modular and tree-shakeable. The core library is ~5kb (minified + gzipped), and you can import only the specific plugins and locales your app needs.

Q: How does it handle Daylight Saving Time (DST)? A: Waktos is DST-aware. Arithmetic operations like add(1, 'day') preserve the same local time across DST transitions, while add(24, 'hour') follows absolute physical time. This ensures consistent behavior for both business logic and duration calculations.


Issues or Feature Requests? Feel free to open an issue or submit a pull request on GitHub. 🤝

Build faster. Ship cleaner. Don’t waste your waktos.