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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@beauwest/business-date-parser

v2.0.0

Published

An opinionated, zero-dependency, fast user input parser for date & times.

Downloads

25

Readme

Business Date Parser Node.js CI

An opinionated, zero-dependency, fast user input parser for date & times. This module is designed to process & parse user input into a Javascript date object.

Date Format Examples

  • c: Current Date
  • y: Yesterday
  • t: Tomorrow
  • f: First day of the month
  • l: Last day of the month
  • +20: 20 days from now
  • -20: 20 days ago
  • 15: The 15th day of the current month
  • 4/15: The 15th day of April of the current year
  • 4/15/2020: April 15th, 2020
  • 5-3-18: May 3rd, 2018
  • 2025-03-01: March 1st, 2025

Time Format Examples

  • c: Current Time
  • +20: 20 minutes from now
  • -20: 20 minutes ago
  • 2: 2:00 PM
  • 02: 2:00 AM
  • 2a: 2:00 AM
  • 2:45: 2:45 PM
  • 2:45a: 2:45 AM
  • 530: 5:30 PM
  • 8:22:34.028: 8:22:34.028 AM

Date & Time format examples

  • Date and time parsing splits based on the first space encountered.
  • y 5p: Yesterday at 5:00PM
  • l 8a: Last day of the month at 8:00AM
  • 2025-03-01 8:22:34.028: March 1st, 2025 at 8:22:34.028 AM

Anything that does not match the rule-based parsing will fall back to Javascript's built-in Date.parse().

Installing

npm i @beauwest/business-date-parser

Getting Started

import {parseDate, parseTime, parseDateAndTime} from 'business-date-parser';

const theFifth = parseDate('5');

const threeDaysFromNow = parseDate('+3');

const quittingTime = parseTime('5');

const snackTime = parseTime('2:30p');

const snackTimeThreeDaysFromNow = parseTime('+3 2:30p');

// Will prefer time parsing when no date part is found in a dateAndTime string
const preferTime = parseDateAndTime('9a', {preferTime: true});

// Default to a specific date when preferring time parsing and there is no date part.
const preferTimeWithSpecificDate = parseDateAndTime('9a', {preferTime: true, defaultDate: '2025-03-01'});