Kite.run

Public code and packages for kite.run

@kiterun/suggest-dates (2.1.0)

Published 2025-05-13 00:31:16 +00:00 by nimbus-deploy

Installation

@kiterun:registry=
npm install @kiterun/suggest-dates@2.1.0
"@kiterun/suggest-dates": "2.1.0"

About this package

Suggest-Dates

Suggest-Dates is a simple date parser that helps you quickly interpret human-friendly date related input strings. It provides suggestions for potential interpretations of the input, making it ideal for applications requiring flexible date handling and natural language processing.

Features

  • Parses natural language date strings into meaningful suggestions.
  • Returns an array of suggestions, where each suggestion includes a descriptive label and the corresponding JavaScript Date object.

Installation

To install suggest-dates, use npm or yarn:

pnpm install @kiterun/suggest-dates

Usage

Suggest-Dates exposes a single function suggestDates(), which takes an input string and returns an array of suggestions.

Example

import { suggestDates } from "@kiterun/suggest-dates";

const input = "tomo";
const suggestions = suggestDates(input);

console.log(suggestions);

Output:

[
	{
		"label": "tomorrow",
		"date": "2025-01-23T15:59:25.525Z"
	},
	{
		"label": "tomorrow at midnight",
		"date": "2025-01-22T18:30:00.000Z"
	},
	{
		"label": "tomorrow at noon",
		"date": "2025-01-23T06:30:00.000Z"
	},
	{
		"label": "tomorrow at 8am",
		"date": "2025-01-23T02:30:00.000Z"
	},
	{
		"label": "tomorrow at 9am",
		"date": "2025-01-23T03:30:00.000Z"
	}
]

API

suggestDates(input: string): Array<{ label: string, date: Date }>

  • input: A natural language date string (e.g., "tomo", "next Monday", "5 minutes ago").
  • Returns: An array of suggestions. Each suggestion is an object with:
    • label: A string describing the interpretation of the input.
    • date: A JavaScript Date object representing the corresponding date and time.

Use Cases

  • Enhancing user experience in scheduling or planning applications.
  • Building smart input fields for dates.
  • Natural language date interpretation for chatbots or virtual assistants.

This module contains code copyrighted code licensed to the author under the MIT license. Yeezy-dates is Copyright (c) 2024 Sai Santhosh Pentakota

suggest-dates is Copyright 2025 Brandon Kalinowski and contains extensive modifications.

No license is provided to anyone besides the author.

Dependencies

Dependencies

ID Version
chrono-node ^2.8.0

Development Dependencies

ID Version
@eslint/compat ^1.2.9
@eslint/js ^9.26.0
@types/node ^22.15.17
eslint ^9.26.0
eslint-config-prettier ^10.1.5
prettier ^3.5.3
terser ^5.39.0
tsup ^8.4.0
typescript ^5.8.3
typescript-eslint ^8.32.0
vitest ^3.1.3

Keywords

nlp dates
Details
npm
2025-05-13 00:31:16 +00:00
17
latest
9.3 KiB
Assets (1)
Versions (3) View all
2.1.0 2025-05-13
2.0.0 2025-05-12
1.1.1 2025-05-02