A fully offline **Nepali (BS) to English (AD) Date Converter** with **unlimited date range, leap year support, and custom formats**.
npm install akuira-ad-bs---
sh
npm install @akuira-ad-bs
`---
π Usage
Import the package into your project:
`jsimport { convertADToBS, convertBSToAD } from "akuira-ad-bs";
`
Hereβs an example of how to use the package in a React app:
`js
import React, { useState } from "react";
import { convertADToBS, convertBSToAD } from "akuira-ad-bs";function App() {
const [adDate, setAdDate] = useState("");
const [bsDate, setBsDate] = useState("");
const [error, setError] = useState("");
const handleADtoBS = () => {
if (!adDate) {
setError("Please enter a valid AD date.");
return;
}
const [year, month, day] = adDate.split("-").map(Number);
try {
const result = convertADToBS(year, month, day);
setBsDate(result.bsDate);
setError("");
console.log("BS Date:", result.bsDate, "Month:", result.bsMonthName);
} catch (err) {
setError("Failed to convert AD to BS. Please check the input.");
}
};
const handleBStoAD = () => {
if (!bsDate) {
setError("Please enter a valid BS date.");
return;
}
const [year, month, day] = bsDate.split("-").map(Number);
try {
const result = convertBSToAD(year, month, day);
setAdDate(result.adDate);
setError("");
console.log("AD Date:", result.adDate, "Month:", result.bsMonthName);
} catch (err) {
setError("Failed to convert BS to AD. Please check the input.");
}
};
return (
Date Converter
{error && {error}
}
type="date"
value={adDate}
onChange={(e) => setAdDate(e.target.value)}
/>
type="date"
value={bsDate}
onChange={(e) => setBsDate(e.target.value)}
/>
);
}export default App;
``---