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

xkernel

v0.1.0

Published

A lightweight TypeScript library providing utility functions for date manipulation and formatting.

Readme

xkernel

A lightweight TypeScript library providing utility functions for date manipulation, formatting, comparison, and more.

Features

  • 🕐 Formatting — Flexible date formatting with token-based templates
  • ➕ Calculation — Add/subtract time units (years, months, days, hours, etc.)
  • 🔍 Comparison — Compare dates, check if same day/month/year, relative time checks
  • 📏 Diff — Calculate differences between dates in various units
  • 🌐 Relative Time — Human-readable relative time ("3 hours ago", "2 days later") with i18n
  • 📅 Parse — Parse date strings and construct dates from parts
  • 📆 Misc — Weekend checks, weekday names, leap year, day of year, timezone helpers

Installation

npm install xkernel
# or
pnpm add xkernel
# or
yarn add xkernel

Usage

import { formatDate, add, diff, fromNow, isWeekend, daysInMonth } from 'xkernel';

// Formatting
formatDate(new Date(2024, 0, 15), 'YYYY-MM-DD');       // '2024-01-15'
formatDate(new Date(2024, 0, 15, 9, 5), 'YYYY/MM/DD HH:mm'); // '2024/01/15 09:05'

// Calculation
add(new Date(2024, 0, 15), 1, 'day');   // 2024-01-16
add(new Date(2024, 0, 15), -1, 'month'); // 2023-12-15

// Diff
diff(new Date(2024, 0, 1), new Date(2024, 0, 10), 'day'); // 9

// Relative time
setRelativeTimeLocale('zh');
fromNow(new Date(2024, 0, 15), new Date(2024, 0, 14)); // '1天后'

// Misc
isWeekend(new Date(2024, 0, 6)); // true (Saturday)
daysInMonth(2024, 2); // 29 (leap year)
isLeapYear(2024); // true

API Reference

Format

  • formatDate(date, format?) — Format a date to string with tokens (YYYY, MM, DD, HH, mm, ss, SSS, etc.)
  • toISOString(date) — Convert to ISO 8601 string

Calculation

  • add(date, amount, unit) — Add/subtract time by unit
  • addDays(date, amount) / addMonths(date, amount) / addYears(date, amount)
  • addHours(date, amount) / addMinutes(date, amount) / addSeconds(date, amount)

Comparison

  • isValidDate(value) — Check if value is a valid Date
  • isDateLike(value) — Check if value can be parsed as date
  • compareDates(a, b) — Compare two dates (-1, 0, 1)
  • isBefore(a, b) / isAfter(a, b) — Relative comparison
  • isSameDay(a, b) / isSameMonth(a, b) / isSameYear(a, b)
  • isToday(date) / isYesterday(date) / isTomorrow(date)
  • isThisWeek(date, refDate?)

Diff

  • diff(dateA, dateB, unit) — Difference in specified unit
  • diffInDays(a, b) / diffInHours(a, b) / diffInMinutes(a, b) / diffInSeconds(a, b)
  • startOfDay(date) / endOfDay(date)
  • startOfWeek(date) / endOfWeek(date)
  • startOfMonth(date) / endOfMonth(date)
  • startOfYear(date) / endOfYear(date)

Relative Time

  • fromNow(date, from?) — Human-readable relative time
  • humanizeDuration(ms) — Convert milliseconds to readable duration
  • setRelativeTimeLocale(locale) — Set locale ('en' | 'zh')

Parse

  • parseDate(value) — Parse string/number to Date
  • parseToTimestamp(value) — Parse to timestamp
  • safeParseDate(value) — Parse, return null on failure
  • fromDateParts(parts) — Construct date from components

Misc

  • isWeekend(date) / isWeekday(date)
  • countWeekdays(start, end) — Count weekdays in range
  • getTimezoneOffset(date?) — Get timezone offset
  • convertToTimezone(date, offsetMinutes) — Convert to target timezone
  • getWeekdayName(date, locale?) — Get weekday name
  • getISODay(date) — ISO weekday number (1=Mon, 7=Sun)
  • daysInMonth(year, month) — Days in given month
  • isLeapYear(year) — Check leap year
  • dayOfYear(date) — Day number in year (1-366)
  • now() — Current timestamp

License

MIT