npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

bangla-date-converter

v1.0.5

Published

A comprehensive Bangla (Bengali) date converter with extensive formatting options

Readme

Bangla Date Converter

npm version npm typescript

A powerful and flexible TypeScript/JavaScript library for converting Gregorian dates to Bangla dates with extensive formatting options. Works seamlessly with both CommonJS and ES Modules!

Features

  • 🔄 Convert any Gregorian date to Bangla date
  • 🌐 Support for both Bengali and English output
  • 🎨 Custom date formatting
  • 🔢 Bengali numeral conversion
  • 🌺 Season information
  • 📅 Weekday support
  • ⌚ Time formatting (12/24 hour)
  • 📝 Relative time formatting
  • 💪 TypeScript support

Quick Start 🚀

Installation

npm install bangla-date-converter

Import the Package

// Using ES Modules
import { BanglaDateConverter } from 'bangla-date-converter';

// Using CommonJS
const { BanglaDateConverter } = require('bangla-date-converter');

Basic Usage 📅

// Create a converter instance
const converter = new BanglaDateConverter(new Date());

// Get Bangla date (returns full date object)
const banglaDate = converter.getBanglaDate();
console.log(banglaDate);
// Output: { year: 1430, date: 15, month: 'পৌষ', day: 'শনিবার', season: 'শীত', monthIndex: 8 }

// Format date with custom template
const formatted = converter.format({
  template: 'DD MM, YY (WW)',
  format: 'bn'
});
console.log(formatted);
// Output: ১৫ পৌষ, ১৪৩০ (শনিবার)

Advanced Formatting Examples 🎨

// Custom formatting with time (12-hour format)
const withTime = converter.format({
  template: 'DD MM, YY TT',
  format: 'en',
  timeFormat: '12h',
  shortMonth: true
});
// Output: "15 Poush, 1430 02:30 PM"

// Relative time formatting
const relative = converter.format({
  relative: true,
  format: 'bn'
});
// Output: "আজ" (today) / "গতকাল" (yesterday) / "আগামীকাল" (tomorrow)

// With ordinal numbers
const withOrdinal = converter.format({
  template: 'DD MM',
  ordinal: true
});
// Output: "১৫ই পৌষ"

Converting Bangla to Gregorian Date 🔄

// Convert Bangla date to Gregorian
// Parameters: (year, month, date)
// Note: month is 0-based (0-11), where 0 = Boishakh, 11 = Choitro
const gregorianDate = BanglaDateConverter.fromBanglaDate(1430, 0, 1);
console.log(gregorianDate);
// Output: 2023-04-14T00:00:00.000Z (1st Boishakh 1430)

API Documentation

Core Methods

getBanglaDate(options?: DateConverterOptions): BanglaDate

Converts a Gregorian date to Bangla date with various formatting options.

interface DateConverterOptions {
  format?: 'bn' | 'en';  // Output language
  showSeason?: boolean;   // Include season information
  showWeekDay?: boolean;  // Include week day
  showTime?: boolean;     // Include time
  timeFormat?: '12h' | '24h'; // Time format
}

format(options?: FormattedDateOptions): string

Formats the Bangla date according to specified options.

interface FormattedDateOptions {
  template?: string;      // e.g., 'DD MM, YY (WW)'
  format?: 'bn' | 'en';   // Output language
  numerals?: 'bn' | 'en'; // Numeral system
  timeFormat?: '12h' | '24h';
  separator?: string;     // Default: ', '
  ordinal?: boolean;      // Use ordinal numbers
  relative?: boolean;     // Use relative time
  shortMonth?: boolean;   // Short month names
  shortWeekDay?: boolean; // Short weekday names
}

Holiday Features 🎉

Get Holidays for Current Month

const converter = new BanglaDateConverter(new Date());
const holidays = converter.getHolidays();
// Returns holidays for the current Bangla month

Get Upcoming Holidays

// Get next 5 upcoming holidays
const upcomingHolidays = converter.getUpcomingHolidays(5);

Get Holidays by Type

// Get all religious holidays
const religiousHolidays = converter.getHolidaysByType('religious');
// Types: 'religious' | 'national' | 'cultural'

Date Manipulation

Add/Subtract Duration

// Add 1 year, 2 months, and 3 days
const futureDate = converter.add(1, 2, 3);

// Subtract 1 year
const pastDate = converter.subtract(1);

Compare Dates

const date1 = new BanglaDateConverter(new Date('2023-04-14'));
const date2 = new BanglaDateConverter(new Date('2023-04-15'));
const comparison = date1.compare(date2); // Returns negative number

Contributing 🤝

Contributions are welcome! Please check our CONTRIBUTE.md for guidelines.

License 📝

This project is licensed under the MIT License - see the LICENSE file for details.

Support 💖

If you find this package helpful, please consider giving it a star on GitHub! For issues and feature requests, please use the GitHub issue tracker.


Made with ❤️ by Md Tanvir Ahamed Shanto for the Bangla community