New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

find-dates

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-dates

Find dates in a string where the format is unknown.

latest
Source
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

find-dates

Current npm package version Build Status

Find dates in a string where the format is unknown.

Usage

npm install find-dates

const { findDates } = require("find-dates");

findDates("My birthday is on June 21st!");
// => [{ match: "June 21st", index: 18 ]

findDates("We're closed on December 24th and December 25th.");
// => [{ match: "December 24th", index: 16 }, { match: "December 25th", index: 34 }]

You may use this library in your Typescript project via:

import { findDates } from "find-dates";

findDates("My birthday is on June 21st!");
// => [{ match: "June 21st", index: 18 ]

findDates("We're closed on December 24th and December 25th.");
// => [{ match: "December 24th", index: 16 }, { match: "December 25th", index: 34 }]

Options

delimiters

Delimiters to use when matching dates formatted as MM/DD/YYYY and MM/DD/YY where the delimiter is /. Some characters must be escaped for use in Regular Expressions. Setting this will override the default options, so if you want to match - and / make sure to include them.

Default: -/

Todo

Work in progress. Here's a rough plan:

  • Figure out default return value
  • Date as string (Ex: October 31st, 2018; Oct. 31, 2018; Oct 31 '18, Oct 31)
    • Day numbers, 01-09, modifiers (st, nd, rd, th)
    • Month variants
    • Optional year
  • Match standard local date formats (mm/dd/yyyy, mm-dd-yyyy, etc...)
    • MM/DD/YYYY and MM/DD/YY
  • Date ranges (from x to y, x through y)
  • Day of week
  • Handle formats like:
    • May the 4th
    • 20th of November
    • May 12th-13th, May 12th and 13th, May 12th or 13th
      • Return as matched or as ['May 12th', 'May 13th']
    • May of 2018
    • May 2018
    • May '18
  • Accept options
    • Only return first
    • Specify which months to search for
    • Change returned format
    • Custom delimiters on MM/DD/YYYY formats
  • More tests
  • Add linting
  • Refactor

License

MIT © Hutson Inc

Keywords

extract

FAQs

Package last updated on 17 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts