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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dateparserjs

v1.0.0

Published

A lightweight natural language date parser (e.g., 'next Monday', '3 days from now').

Downloads

4

Readme

# DateParserJS

A lightweight natural language date parser that interprets and parses common date expressions, such as:

- `"today"`
- `"tomorrow"`
- `"yesterday"`
- `"3 days from now"`
- `"next Monday"`
- `"end of the month"`

## Features

- **Simple parsing** for common relative dates like "today," "tomorrow," and "yesterday."
- **Support for advanced relative dates**, like `"3 days from now"`, `"next Monday"`, `"1 week ago"`, and more.
- **Weekday parsing** for phrases like `"next Monday"`, `"last Tuesday"`, and other variations.
- **Advanced parsing with Chrono-node**, allowing for flexible and complex date expressions.
- **Special handling** for relative periods like `"next month"`, `"start of the week"`, `"end of the quarter"`, and more.

## Installation

To get started with `DateParserJS`, you need to install the package via npm:

```bash
npm install dateparserjs

Usage

Simple Date Parser (Using simple.js)

The simple parser can handle basic relative dates, such as "today," "tomorrow," and "yesterday."

const DateParserJS = require('dateparserjs/src/simple');

const parser = new DateParserJS();
console.log(parser.parse("today"));           // Returns today's date
console.log(parser.parse("tomorrow"));       // Returns tomorrow's date
console.log(parser.parse("yesterday"));      // Returns yesterday's date
console.log(parser.parse("3 days from now"));// Returns date 3 days from now
console.log(parser.parse("next Monday"));    // Returns next Monday's date

Advanced Date Parser (Using advanced.js)

The advanced parser can handle more complex expressions like relative dates ("3 weeks ago") and specific periods ("next month", "start of the year").

const AdvancedDateParserJS = require('dateparserjs/src/advanced');

const parser = new AdvancedDateParserJS();
console.log(parser.parse("today"));           // Returns today's date
console.log(parser.parse("tomorrow"));       // Returns tomorrow's date
console.log(parser.parse("1 week ago"));     // Returns date 1 week ago
console.log(parser.parse("next month"));     // Returns the start of next month
console.log(parser.parse("end of the week"));// Returns end of the current week

Example Script

You can run an example script to see both parsers in action. In the examples/ folder, there is a file called basic.js which demonstrates the usage of the parsers.

// examples/basic.js
const SimpleDateParserJS = require('dateparserjs/src/simple');
const AdvancedDateParserJS = require('dateparserjs/src/advanced');

const simpleParser = new SimpleDateParserJS();
const advancedParser = new AdvancedDateParserJS();

console.log("Simple Parser:");
console.log("Today:", simpleParser.parse("today"));
console.log("Tomorrow:", simpleParser.parse("tomorrow"));
console.log("Yesterday:", simpleParser.parse("yesterday"));
console.log("Next Monday:", simpleParser.parse("next Monday"));
console.log("3 days from now:", simpleParser.parse("3 days from now"));

console.log("\nAdvanced Parser:");
console.log("Today:", advancedParser.parse("today"));
console.log("Tomorrow:", advancedParser.parse("tomorrow"));
console.log("1 week ago:", advancedParser.parse("1 week ago"));
console.log("Next month:", advancedParser.parse("next month"));
console.log("End of the week:", advancedParser.parse("end of the week"));

To run the example script, execute:

node examples/basic.js

Testing

The project uses Jest for testing. To run the tests, you can execute the following command:

npm test

Example Tests

You can find the test file in the test/ folder as dateparser.test.js. Jest tests include checks for various date expressions and their expected outputs.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Contributing

Contributions are welcome! Feel free to fork the repository and submit a pull request.