# BanglaDateJS

BanglaDateJS is a lightweight JavaScript/TypeScript library that converts JavaScript `Date` objects into Bangla date format.

## Installation

You can install `bangladatejs` via npm:

```sh
npm install bangladatejs
```

## Usage

### Using in Node.js

```js
const { formatBanglaDate, DateFormatType } = require("bangladatejs");

const date = new Date();
const banglaDate = formatBanglaDate(date, DateFormatType.Long);
console.log(banglaDate); // Outputs Bangla formatted date
```
## DateFormatType Type 
There are three types of date formats available in BanglaDateJS:
- `DateFormatType.Long`: Outputs the date in the format "১২ জুন, ২০১৩"
- `DateFormatType.Slash`: Outputs the date in the format "১২/০৬/২০১৩"
- `DateFormatType.Dash`: Outputs the date in the format "১২-০৬-২০১৩"

### Using in Express (Backend)

```js
const express = require("express");
const { formatBanglaDate, DateFormatType } = require("bangladatejs");


const app = express();

app.get("/bangla-date", (req, res) => {
    const date = new Date();
    res.json({ banglaDate: formatBanglaDate(date, DateFormatType.Long) });
});

app.listen(3000, () => console.log("Server is running on port 3000"));
```

### Using in Next.js (Frontend)

```tsx
import { useEffect, useState } from "react";
import { formatBanglaDate, DateFormatType} from "bangladatejs";


export default function Home() {
    const [banglaDate, setBanglaDate] = useState("");

    useEffect(() => {
        const date = new Date();
        setBanglaDate(formatBanglaDate(date,DateFormatType.Long));
    }, []);

    return <div>Bangla Date: {banglaDate}</div>;
}
```

## API

### `BanglaDate.convert(date: Date): string`
Converts a JavaScript `Date` object into a Bangla date string.

## License

This project is licensed under the ISC License.

## Author

Created by [Fuad Hasan](https://github.com/fuad-hasan-safat).

