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

@codianz/better-date

v0.1.6

Published

The Date object easier to work with.

Downloads

6

Readme

Better Date

concept

BDate is a DATE object with a date and time and an arbitrary UTC offset.

features

  • Convert a specific local time to a different local time.
  • Interoperating with Javascript Date objects.
  • Implementation of getters and setters for each element.
  • Addition / subtraction does not change the state of the instance.
  • Months start at 1, not 0.
  • Supports method chains.
  • Supports formatting.
  • Some utilities.

usage

import { BDate } from "@codianz/better-date";

// You can calculate a specific time on Earth with any UTC offset.
{
  const bd_0900 = BDate.from("2020-01-01T09:00:00.00+09:00"); // local date time with offset +09:00
  console.log(bd_0900.toString()); // 2020/01/01 09:00:00 (local time)
  console.log(bd_0900.toISOStringWithOffset()); // 2020-01-01T09:00:00.000+09:00
  console.log(bd_0900.toISOString()); // 2020-01-01T00:00:00.000Z
  console.log(bd_0900.isUTC()); // false
  console.log(bd_0900.utcOffsetMinutes); // 540

  const bd_UTC = bd_0900.toUTC(); // UTC date time
  console.log(bd_UTC.toString()); // 2020/01/01 00:00:00 (local time)
  console.log(bd_UTC.toISOStringWithOffset()); // 2020-01-01T00:00:00.000+00:00
  console.log(bd_UTC.toISOString()); // 2020-01-01T00:00:00.000Z
  console.log(bd_UTC.isUTC()); // true
  console.log(bd_UTC.utcOffsetMinutes); // 0

  const bd_m0200 = bd_0900.newUTCOffset("-02:00"); // local date time with offset -02:00
  console.log(bd_m0200.toString()); // 2019/12/31 22:00:00 (local time)
  console.log(bd_m0200.toISOStringWithOffset()); // 2019-12-31T22:00:00.000-02:00
  console.log(bd_m0200.toISOString()); // 2020-01-01T00:00:00.000Z
  console.log(bd_m0200.isUTC()); // false
  console.log(bd_m0200.utcOffsetMinutes); // -120
}

// All date and time calculations are performed using the UTC offset time held by BDate.
{
  const bd = BDate.fromLocalDateTimeValues("-03:30", 2020, 1, 1);
  console.log(bd.toString()); // 2020/01/01 00:00:00
  const bd2 = bd
    .addYears(1)
    .addMonths(2)
    .addDays(3)
    .addHours(4)
    .addMinutes(5)
    .addSeconds(6)
    .addMilliseconds(7);
  console.log(bd2.toISOStringWithOffset()); // 2021-03-04T04:05:06.007-03:30
  console.log(bd2.toISOString()); // 2021-03-04T07:35:06.007Z
}

// Javascript Date object can be converted to BDate.
{
  const jsDate = new Date("2020-01-01T00:00:00.00+01:00");

  const bd = BDate.fromJsDate(jsDate);
  console.log(bd.toISOStringWithOffset()); // 2020-01-01T00:00:00.000+01:00
  console.log(bd.toISOString()); // 2019-12-31T23:00:00.000Z
  console.log(jsDate.toISOString()); // 2019-12-31T23:00:00.000Z

  const bd2 = bd.addDays(1);
  const jsDate2 = bd2.toJsDate();
  console.log(bd2.toISOStringWithOffset()); // 2020-01-02T00:00:00.000+01:00
  console.log(bd2.toISOString()); // 2020-01-01T23:00:00.000Z
  console.log(jsDate2.toISOString()); // 2020-01-01T23:00:00.000Z

  // The UTC offset of DATE varies depending on the execution environment.
  // This is the source of confusion!!
  console.log(jsDate2.toString()); // Sun Feb 02 2020 08:00:00 GMT+0900 (Japan Standard Time)
}

// When initialized with a Date object, the BDate's UTC offset is automatically initialized.
// (Running on JST +09:00)
{
  const jsDate = new Date(); // now
  const bd = BDate.fromJsDate(jsDate); // utc offset is taken from jsDate
  console.log(jsDate.getTimezoneOffset()); // -540 (UTC offset of Japan)
  console.log(bd.utcOffsetMinutes); // 540
}