open-index/open-npm huggingface dataset:
npm package: @one-tree-tech/tiny-date-parser
Description: Simple and tiny parser for strings to dates
Author: Kirk Wood
Latest version: 0.2.0

# @one-tree-tech/tiny-date-parser

A lightweight and simple date parser for JavaScript and TypeScript. Converts date strings into 
JavaScript `Date` objects with minimal overhead.

## Features

- ✨ Tiny and lightweight
- 🚀 Fast date parsing
- 📦 Supports both ES Modules and CommonJS
- 📝 Full TypeScript support with type definitions
- 🧪 Well-tested with Vitest
- 🎯 Zero external dependencies

## Motivation

I found it frustrating that there was no lightweight and simple date parser for JavaScript. I made the assumption that 
most dates fall into one of three formats: YMD, DMY, or MDY.

When parsing YMD, a separator is usually present and the year is always 4 digits. Otherwise, the parser makes minimal 
assumptions about the separator.

I also did **not** want a complete date-handling library. Often, you just need to convert user input into a `Date` 
object.

## Installation

```bash
npm install @one-tree-tech/tiny-date-parser
```

## Usage

There are two functions: `parseDayFirst` and `parseMonthFirst`. Both of them handle YMD formats as long as there is a 
separator and 4-digit year. Also, it is assumed that a 2-digit month and day will be provided. Any non-numeric character 
can be used as a separator.

### ES Modules

```javascript
import { parseDayFirst, parseMonthFirst } from '@one-tree-tech/tiny-date-parser';

const date = parseDayFirst('2024-03-18');
const date = parseDayFirst('18-03-2024');
const date = parseMonthFirst('03-18-2024');
console.log(date); // Date object
```

### CommonJS

```javascript
const { parseDayFirst, parseMonthFirst } = require('@one-tree-tech/tiny-date-parser');

const date = parseDayFirst('2024-03-18');
const date = parseDayFirst('18-03-2024');
const date = parseMonthFirst('03-18-2024');
console.log(date); // Date object
```


## Development

### Prerequisites

- Node.js >= 14.0.0
- npm or yarn

### Build

```bash
npm run build
```

This generates:
- `dist/esm/` - ES Module files
- `dist/cjs/` - CommonJS files
- `dist/types/` - TypeScript definitions

### Test

```bash
npm test
```

Run tests with UI:
```bash
npm run test:ui
```

### Clean

```bash
npm run clean
```

## License

MIT © Kirk Wood