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

chronoskit

v0.0.0-beta.5

Published

Localized date formatter for Persian and Gregorian calendars.

Readme

📆 ChronosKit

A lightweight TypeScript utility for consistent and localizable date-time formatting with support for Gregorian and Persian (Jalali) calendars using the native Intl.DateTimeFormat.


✨ Features

  • ✅ Localized date-time formatting (en-US, fa-IR)
  • 🍍 Support for Gregorian and Persian calendars
  • 🔁 Caching for Intl.DateTimeFormat to improve performance
  • 📄 Converts to ISO-like strings: YYYY-MM-DDTHH:mm:ss
  • 🔍 Graceful handling of invalid dates

📦 Installation

npm install chronoskit

🛠 Usage

import {
  toDateTime,
  toDateTimePersian,
  toDateTimePersianFa,
  generateFormattedDateTimeObject
} from 'chronoskit'

// Standard Gregorian ISO string
toDateTime(new Date())
// => "2025-05-13T12:45:00"

// Persian calendar in ISO-like format
toDateTimePersian('2025-05-13')
// => "1404-02-23T00:00:00"

// Persian + Farsi locale (output is still numeric, but culturally formatted)
toDateTimePersianFa(Date.now())
// => "۱۴۰۴-۰۲-۲۳T۱۶:۳۰:۵۱"

🔧 API Reference

toDateTime(param, calendar?, lang?)

| Param | Type | Default | Description | | ---------- | -------------------------- | ----------- | --------------------- | | param | string \| number \| Date | required | Any valid date input | | calendar | 'gregory' \| 'persian' | 'gregory' | Which calendar to use | | lang | 'en-US' \| 'fa-IR' | 'en-US' | Which locale to use |

Returns: YYYY-MM-DDTHH:mm:ss as a string or 'INVALID_DATE' if input is invalid.


toDateTimePersian(param)

Shortcut for:

toDateTime(param, 'persian', 'en-US')

toDateTimePersianFa(param)

Shortcut for:

toDateTime(param, 'persian', 'fa-IR')

generateFormattedDateTimeObject(timestamp, calendar?, lang?)

Parses a timestamp into an object like:

{
  year: '2025',
  month: '05',
  day: '13',
  hour: '12',
  minute: '45',
  second: '00'
}

🧪 Example Output

toDateTime(new Date('2025-05-13T12:00:00+03:30'))
// "2025-05-13T12:00:00"

toDateTimePersianFa(Date.now())
// "1404-02-23T13:15:00"

📂 Internal Types

| Type | Description | | -------------------- | -------------------------------------------- | | DateTimeString | Template literal "YYYY-MM-DDTHH:mm:ss" | | DateTimeParts | { year, month, day, hour, minute, second } | | InvalidDateLiteral | 'INVALID_DATE' |