0.0.23 • Published 2 years ago

date-parrot v0.0.23

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

DateParrot

DateParrot parses natural language into a unified schedule object or ISO date.

This package is in a very early stage and not yet production ready.

Open Playground

Installation

npm install date-parrot

Usage

import { parseDate } from 'date-parrot'

parseDate('lets go out tomorrow')

// =>
// {
//   date: [TOMORROW_AS_ISO_STRING],
//   match: {
//     index: 12,
//     length: 8,
//     text: 'tomorrow',
//   },
// }
import { parseSchedule } from 'date-parrot'

parseSchedule('every second day')

// =>
// {
//   schedule: {
//     repeatFrequency: 'P2D',
//     startDate: '[NOW_AS_ISO_STRING]',
//   },
//   match: {
//     index: 0,
//     length: 16,
//     text: 'every second day',
//   },
// }
import { parseSchedule } from 'date-parrot'

parseSchedule('eat donuts on every 3rd friday')

// =>
// {
//   schedule: {
//     repeatFrequency: 'P1W',
//     startDate: '[NEXT_FRIDAY_AS_ISO_STRING]',
//   },
//   match: {
//     index: 11,
//     length: 16,
//     text: 'every 3rd friday',
//   },
// }

Localization

By default DateParrot only parses english but you can add support for other languages by adding a locales property to the config of the parser functions.

It takes an array of locale identifiers (e.g. ['en', 'de']).

import { parseDate } from 'date-parrot'

parseDate('lass uns morgen ausgehen', { locales: ['de'] })

// =>
// {
//   date: [TOMORROW_AS_ISO_STRING],
//   match: {
//     index: 9,
//     length: 6,
//     text: 'morgen',
//   },
// }
0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago