# find-dates

> Find dates in a string where the format is unknown.

Latest version **0.1.3** (published 2019-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install find-dates
pnpm add find-dates
yarn add find-dates
bun add find-dates
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2019-02-17 |
| First published | 2019-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | AustinLeeGordon |
| Maintainers | austinleegordon |
| Keywords | extract, parse, find, date, string, format |

## Links

- npm: https://www.npmjs.com/package/find-dates
- Repository: https://github.com/hutsoninc/find-dates
- Homepage: https://github.com/hutsoninc/find-dates#readme
- Issues: https://github.com/hutsoninc/find-dates/issues
- npm.io page: https://npm.io/package/find-dates

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2019-02-17
- 0.1.2 — 2019-02-17
- 0.1.0 — 2019-02-17
- 0.0.1 — 2019-02-15
- 0.0.0 — 2019-02-15

## README

# find-dates

[![Current npm package version](https://img.shields.io/npm/v/find-dates.svg)](https://www.npmjs.com/package/find-dates) [![Build Status](https://travis-ci.com/hutsoninc/find-dates.svg?branch=master)](https://travis-ci.com/hutsoninc/find-dates)

Find dates in a string where the format is unknown.

## Usage

`npm install find-dates`

```js
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:

```ts
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:

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

## License

MIT © [Hutson Inc](https://www.hutsoninc.com)

---
_Source: https://npm.io/package/find-dates · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
