bn-calendar
v1.3.3
Published
Comprehensive Bengali calendar system library built for any JavaScript and TypeScript environment.
Maintainers
Keywords
Readme
Bangla Calendar
Comprehensive Bengali calendar system library built for any JavaScript and TypeScript environment.
bn-calendar is a comprehensive Bengali calendar system library built for any JavaScript and TypeScript environment. It supports creation, manipulation, and conversion between Bengali and Gregorian calendars with full support for both 'revised-2019' (default) and 'revised-1966' variants.
Install
NPM
npm i bn-calendarPNPM
pnpm add bn-calendarYARN
yarn add bn-calendarImport
import { BanglaCalendar } from 'bn-calendar';Quick Examples
BanglaCalendar - The class to create, manipulate, and convert dates between the Bangla and Gregorian calendar systems.
It supports two calendar variants:
'revised-2019'(default) and'revised-1966'.
import { BanglaCalendar } from 'bn-calendar';
// 1. Current date in Bangla calendar
const today = new BanglaCalendar();
console.log(today.toString());
// Output: "শুক্রবার, ৯ ফাল্গুন, ১৪৩২ [বসন্ত]"
// 2. From Gregorian date string
const date1 = new BanglaCalendar('2023-04-14');
console.log(date1.toJSON());
// Output: "১৪৩০-০১-০১"
// 3. From JavaScript Date object
const date2 = new BanglaCalendar(new Date(2023, 3, 14));
console.log(date2.getMonthName());
// Output: "বৈশাখ"
// 4. From specific Bangla components (Year, Month, Date)
const date3 = new BanglaCalendar(1430, 1, 1);
console.log(date3.toDate());
// Output: Fri Apr 14 2023 00:00:00 GMT+0000
// 5. Using Bangla digits directly
const date4 = new BanglaCalendar('১৪৩০', '১', '১');
console.log(date4.toStringEn());
// Output: "Shukrobar (Friday), 1 Boishakh, 1430 [Grisma (Summer)]"Read full documentation: bn-calendar.vercel.app
Features
- Bidirectional Conversion: Seamlessly convert dates between Gregorian and Bengali calendar systems.
- Multiple Variants: Full support for both
'revised-2019'(official Bangladesh calendar) and'revised-1966'leap year rules. - Immutable by Design:
BanglaCalendarobjects are strictly immutable. All date manipulation methods (addDays,addMonths, etc.) andtoDate()return fresh instances/objects without side effects. - Rich API: Extensive methods for date manipulation, formatting, and calculations.
- Universal Utilities: Handy functions to handle conversion between Bangla (
০-৯) and Latin (0-9) digits. - Lightweight & Fast: Zero dependencies, fully tree-shakable, and optimized for performance.
- Universal Compatibility: Works seamlessly in Node.js, browsers, and any JS/TS environment.
- Type-Safe: Written in TypeScript with comprehensive type definitions.
🔗 Related Packages
License
This project is licensed under the Apache License 2.0 with the following additional requirement:
Additional Requirement:
Any fork, derivative work, or redistribution of this project must include clear attribution to Nazmul Hassan in both the source code and any publicly available documentation.
You are free to use, modify, and distribute this project under the terms of the Apache 2.0 License, provided that appropriate credit is given.
Built with ❤️ by Nazmul Hassan

