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

@bedrockio/chrono

v0.12.0

Published

Minimal library for working with dates.

Readme

Chrono

Chrono is a minimal library to simplify working with dates in Javascript. It has built-in locale and timezone support.

Concepts

Installation

yarn install @bedrockio/chrono

Documentation

https://bedrockio.github.io/chrono/

DateTime

The DateTime object maintains basic parity with the built-in Date object, however is immutable and has a number of additional methods:

import { DateTime } from '@bedrockio/chrono';

const now = new DateTime();

// Unlike JS dates, the "set" methods return
// a new instance and do not mutate the date.
const january = now.setMonth(0);

Timezones and locales can be set on each instance or globally:

// Sets the timezone for this DateTime
const dt = new DateTime({
  timeZone: 'America/New_York',
  locale: 'en-US',
});

DateTime.setTimeZone('America/New_York');
DateTime.setLocale('en-US');

Date Formatting

For common formats there are convenience methods. For full control, the format method accepts a locale options object or a token string.

Convenience Methods

const dt = new DateTime('2020-01-01T14:00:00.000Z', {
  timeZone: 'America/New_York',
});

dt.toLong();   // "January 1, 2020 at 9:00am"
dt.toMedium(); // "Jan 1, 2020, 9:00am"
dt.toShort();  // "1/1/2020, 9:00am"

dt.toDateLong();   // "January 1, 2020"
dt.toDateMedium(); // "Jan 1, 2020"
dt.toDateShort();  // "1/1/2020"

dt.toTimeLong();   // "9:00:00am"
dt.toTimeMedium(); // "9:00am"
dt.toTimeShort();  // "9am"

dt.toLongWithZone();       // "January 1, 2020 at 9:00am GMT-5"
dt.toLongWithZone('long'); // "January 1, 2020 at 9:00am Eastern Standard Time"
dt.toTimeWithZone();       // "9:00am GMT-5"

Locale Formatting

Passing an object to format uses Intl.DateTimeFormat to produce a human-readable string in a specific locale. The locale used in order will be:

  • Passed in the options to format
  • The internal locale of the DateTime
  • The globally set locale
  • The system locale
const dt = new DateTime('2020-01-01T14:00:00.000Z', {
  timeZone: 'America/New_York',
});

dt.format({
  year: 'numeric',
  month: 'long',
  day: 'numeric',
});
// "January 1, 2020"

Token Formatting

Passing a string will format the date using tokens and ignoring locales.

const dt = new DateTime('2020-01-01T14:00:00.000Z', {
  timeZone: 'America/New_York',
});

dt.format('h:mm a');   // "9:00 am"
dt.format('M/d/yyyy'); // "1/1/2020"

Supported tokens are:

| Token | Description | | ----- | -------------------------------------------- | | yy | two-digit year | | yyyy | four to six digit year | | M | unpadded month | | MM | padded month | | d | unpadded day of the month | | dd | padded day of the month | | h | unpadded hour in 12-hour time | | hh | padded hour in 12-hour time | | H | unpadded hour in 24-hour time | | HH | padded hour in 24-hour time | | m | unpadded minute | | mm | padded minute | | s | unpadded second | | ss | padded second | | a | lowercase meridiem (am/pm) | | A | uppercase meridiem (AM/PM) | | Z | narrow timezone offset (-5) | | ZZ | short timezone offset (-0500) | | ZZZ | long timezone offset (-05:00) | | ZZZZ | short timezone name (EST) | | ZZZZZ | long timezone name (Eastern Standard Time) |

Native Date Compatibility

DateTime provides passthroughs to the standard Date methods (toUTCString, toLocaleString, toJSON, etc.) so that it can stand in for a Date in code that calls them. Each delegates directly to the underlying Date and produces exactly what the spec defines.

The one exception is toString, which deliberately diverges from the native form to produce a more readable result for implicit stringification (template literals, logs, errors). Use dt.date.toString() if you need the literal native format.

Interval

The Interval object represents an interval of time:

import { DateTime, Interval } from '@bedrockio/chrono';

const lastYear = new DateTime().rewind(1, 'year');
const nextYear = new DateTime().advance(1, 'year');

const interval = new Interval(lastYear, nextYear);

// The number of days in this interval.
const days = interval.days();

Time

The Time object represents a generic time of day, with no associated date or timezone. It is useful for representing times in the abstract — for scheduling, display, or comparison — without binding to a specific calendar moment.

import { Time } from '@bedrockio/chrono';

const noon = new Time(12, 0);
const meeting = new Time('9:30am');
const duration = new Time(35100000); // 9:45:00.000

// Like DateTime, Time is immutable.
const later = meeting.advance(15, 'minutes'); // "9:45am"

Hours greater than 24 are allowed and preserved (not normalized), which lets a Time represent times that spill past midnight — useful for broadcast schedules or late-night programming:

new Time('25:30').toISOString(); // "25:30:00.000"