1.0.1 β€’ Published 8 months ago

english-nepali-calendar v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

πŸ“¦ Installation

Install the package using npm:

npm install english-nepali-calendar

πŸš€ Usage

Import the library

You can import the library and use its functions to convert dates between the English (Gregorian) and Nepali (Bikram Sambat) calendars.

import { englishToNepali, nepaliToEnglish } from "english-nepali-calendar";

Convert English to Nepali

Pass an English (Gregorian) date as a Date object to the englishToNepali function:

const nepaliDate = englishToNepali(new Date("1997-11-19"));
console.log(nepaliDate);
// Output: { year: 2054, month: 8, day: 4 }

Convert Nepali to English

Provide a Nepali (Bikram Sambat) date as an object { year, month, day } to the nepaliToEnglish function:

const englishDate = nepaliToEnglish({ year: 2029, month: 2, day: 9 });
console.log(englishDate);
// Output: 1972-05-22T00:00:00.000Z

πŸ“– Example

Here’s a full example demonstrating both conversions:

import { englishToNepali, nepaliToEnglish } from "english-nepali-calendar";

const nepaliDate = englishToNepali(new Date("1997-11-19"));
console.log("Nepali Date:", nepaliDate);
// Output: Nepali Date: { year: 2054, month: 8, day: 4 }

const englishDate = nepaliToEnglish({ year: 2029, month: 2, day: 9 });
console.log("English Date:", englishDate);
// Output: English Date: 1972-05-22T00:00:00.000Z
1.0.1

8 months ago

1.0.0

8 months ago