super-calendar
v1.0.0
Published
A powerful and versatile JavaScript library for converting human-friendly date inputs into date objects. Super Calendar provides date parsing, natural language date recognition, and international date support, making it easy to work with dates in a user-f
Downloads
19
Maintainers
Keywords
Readme
Super-calendar
Super-calendar is a powerful and versatile JavaScript library for converting human-friendly date inputs into date objects.
Installation
You can install Super-calendar via npm, yarn, pnpm:
npm
npm install super-calendar
yarn
yarn add super-calendar
pnpm
pnpm install super-calendar
Usage
import { parseDate } from "super-calendar";
const dateSuggestions = parseDate({ query: "monday" });
Options
/**
* Takes a string of fallback dates, if parser is not able
* to parse the string input these predefined string values will
* generate dates and return in suggestions array
* */
fallback?: string[];
/**
* Whether to parseTime, default is true
* */
parseTime?: boolean;
/**
* Default hour to apply to parsed / suggested dates
* */
hour?: number | null;
/**
* Default minute to apply to parsed / suggested dates
* */
minute?: number | null;
/**
* Default second to apply to parsed / suggested dates
* */
second?: number | null;
/**
* Options like timezone or forwardDate for chrono node
* */
options: chrono.ParsingOption | undefined[]
/**
* Reference date for chrono to improve parsing to the right date
* */
ref?: Date | undefined;
Detailed Usage Example
Here's a more detailed usage example demonstrating different inputs:
- Run in root folder
pnpm pack
# or
yarn pack
# or
npm pack
- Install the package in example folder and run the developement server.
pnpm install
pnpm run dev
# or
yarn install
yarn run dev
# or
npm install
npm run dev
Contributing
Contributions are welcome! If you have suggestions for improvements, new features, or bug fixes, feel free to open an issue or submit a pull request. Please follow the contribution guidelines when contributing to this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.