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

tk-date-library

v1.0.1

Published

a simple date library

Readme

Date Library

Travis (.com) GitHub code size in bytes

Description

A simple date library which utilizes the JS Date Object to perform four useful operations

  1. instantiating a date object given a date string
  2. convert the date object into readable values
  3. format a date given a mask string
  4. discover when a date occurs/occured

This library can also be found on NPM

Installation (coming soon)

Run the Following command in your project's directory:

npm i tk-date-library --save

Once installed, require it on the top of your applications main point of entry (index.js):

require('tk-date-library')

Functions

Date Object Instantiation

The date object can be instantiated in four ways:

Examples

const myDateA = new D() // empty
const myDateB = new D() // value (milliseconds)
const myDateC = new D('06/09/1996') // dateString
const myDateD = new D('1996, 6, 9, 0, 0, 0') // individual date/time components

Instantiates a Date Object: D { date: 2019-08-05T03:00:26.598Z }

Get Values

The following classes provide human readable values for:

  • year
  • month
  • date
  • hour
  • minutes
  • seconds

Examples

const myDate = new D('1996, 6, 9, 4, 2, 0')

console.log(myDate.year()) // 1996
console.log(myDate.month ()) // June
console.log(myDate.day()) // 9
console.log(myDate.hours()) // 4
console.log(myDate.mins()) // 2
console.log(myDate.secs()) // 0

Returns the value as a String

Convert "Mask" String to Formatted Date

The following method takes in a "mask" string and produces an acceptable formatted date.

List of formatting characters

  • 'Y' -> 2019
  • 'y' -> 19
  • 'M' -> July
  • 'm' -> Jul
  • 'D' -> 01
  • 'd' -> 1
  • 'H' -> 05
  • 'h' -> 5
  • 'I' -> 08
  • 'i' -> 8
  • 'S' -> 04
  • 's' -> 4

Examples

const myDate = new D('1996, 6, 9, 4, 2, 0')

console.log(myDate.format()) // 1996 June 09
console.log(myDate.format('y/m/d')) // 96/Jun/9
console.log(myDate.format('H:I:S')) // 04:02:00
console.log(myDate.format('h:i:s')) // 4:2:0
console.log(myDate.format('Y0M0D h:I:S')) // 1996-June-09 4:02:00

Returns a formatted date as a String

Find When a Date Occurs/Occured

The following method compares the date owned by your class with the current date(when the method is executed)

Examples

// NOTE: As time continues, the expected output will also change

const a = new D(2019, 0, 2, 3, 4, 5)
console.log(a.when()) // 6.xx months ago

const b = new D(2019, 9, 2, 3, 4, 5)
console.log(b.when()) // 3.xx months from now

const c = new D(2024, 9, 2, 3, 4, 5)
console.log(c.when()) // 5.xx years from now

const d = new D(2019, 6, 30, 3, 4, 5)
console.log(d.when()) // 3.xx days from now

Returns a when a date will occur as a String