7.0.0 • Published 2 years ago

bangla-calendar v7.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
2 years ago

📅 bangla-calendar Stars · License · GitHub issues

A small JavaScript library to convert any valid JavaScript date to Bangla date.

Install

$ npm i bangla-calendar

Usage

const {
  getDate,
  getDay,
  getWeekDay,
  getMonth,
  getYear,
} = require('bangla-calendar');

or

import {
  getDate,
  getDay,
  getMonth,
  getWeekDay,
  getYear,
} from 'bangla-calendar';
const date1 = new Date('August 16 2019 06:22:03');

getDate(date1); //output: শুক্রবার, ১ ভাদ্র, ১৪২৬
getDate(date1, { format: 'DD/MM/YYYY' }); //output: ০১/০৫/১৪২৬

Methods

getDate(date, {})

This method returns full Bangla date for a given date.

Examples

const date1 = new Date('August 16 2019 06:22:03');

getDate(date1); //output: শুক্রবার, ১ ভাদ্র, ১৪২৬
getDate(date1, { format: 'DD/MM/YY', calculationMethod: 'BD' }); //output: ০১/০৫/২৬
getDate(date1, { format: 'DD/MM/YYYY', calculationMethod: 'BD' }); //output: ০১/০৫/১৪২৬
getDate(date1, { format: 'DD/MM/YYYYb', calculationMethod: 'BD' }); //output: ০১/০৫/১৪২৬ (বঙ্গাব্দ)
getDate(date1, { format: 'D MMMM, YYYY', calculationMethod: 'BD' }); //output: ১ ভাদ্র, ১৪২৬
getDate(date1, { format: 'D MMMM, YYYYb', calculationMethod: 'BD' }); //output: ১ ভাদ্র, ১৪২৬ (বঙ্গাব্দ)

Parameters

ParameterTypeExample
dateJavaScript datenew Date('August 16 2019 06:22:03')
optionsobject{ format: 'D MMMM, YYYY', calculationMethod: 'BD' }

getDay(date, {})

This method returns the day of the Bangla month of the given date.

Examples

const date1 = new Date('August 16 2019 06:22:03');

getDay(date1); //output: ১
getDay(date1, { format: 'DD', calculationMethod: 'BD' }); //output: ০১
getDay(date1, { format: 'D', calculationMethod: 'BD' }); //output: ১

Parameters

ParameterTypeExample
dateJavaScript datenew Date('August 16 2019 06:22:03')
optionsobject{ format: 'D', calculationMethod: 'BD' }

getWeekDay(date, {})

This method returns the day of the Bangla week of the given date.

Examples

const date1 = new Date('August 16 2019 06:22:03');

getWeekDay(date1); //output: শুক্রবার
getWeekDay(date1, { format: 'eeee', calculationMethod: 'BD' }); //output: শুক্রবার
getWeekDay(date1, { format: 'eee', calculationMethod: 'BD' }); //output: শুক্র

Parameters

ParameterTypeExample
dateJavaScript datenew Date('August 16 2019 06:22:03')
optionsobject{ format: 'eeee', calculationMethod: 'BD' }

getMonth(date, {})

This method returns the Bangla month of a given date.

Examples

const date1 = new Date('August 16 2019 06:22:03');

getMonth(date1); //output: ভাদ্র
getMonth(date1, { format: 'M', calculationMethod: 'BD' }); //output: ১
getMonth(date1, { format: 'MM', calculationMethod: 'BD' }); //output: ০১
getMonth(date1, { format: 'MMMM', calculationMethod: 'BD' }); //output: ভাদ্র

Parameters

ParameterTypeExample
dateJavaScript datenew Date('August 16 2019 06:22:03')
optionsobject{ format: 'MMMM', calculationMethod: 'BD' }

getYear(date, {})

This method returns the Bangla year of a given date.

Examples

const date1 = new Date('August 16 2019 06:22:03');

getYear(date1); //output: ১৪২৬
getYear(date1, { format: 'YY', calculationMethod: 'BD' }); //output: ২৬
getYear(date1, { format: 'YYYY', calculationMethod: 'BD' }); //output: ১৪২৬
getYear(date1, { format: 'YYYYb', calculationMethod: 'BD' }); //output: ১৪২৬ (বঙ্গাব্দ)

Parameters

ParameterTypeExample
dateJavaScript datenew Date('August 16 2019 06:22:03')
optionsobject{ format: 'YYYY', calculationMethod: 'BD' }

Options

calculationMethod (string)

CountryToken
BangladeshBD
IndiaIN

format (string)

UnitTokenResult examples
DayD১, ২, ৩, ৪, ..., ৩০, ৩১
DD০১, ০২, ০৩, ০৪, ..., ৩০,
Weekdayeeeশুক্র, শনি, রবি, ..., বৃহস্পতি
eeeeশুক্রবার, শনিবার, রবিবার, ..., বৃহস্পতিবার
MonthM১, ২, ৩, ৪, ..., ১১, ১২
MM০১, ০২, ০৩, ০৪, ..., ১১, ১২
MMMMবৈশাখ, জ্যৈষ্ঠ, আষাঢ়, শ্রাবণ, ..., ফাল্গুন, চৈত্র
YearYY২০, ২১, ২২, ..., ২৫, ২৬
YYYY১৪২০, ১৪২১, ১৪২২, ..., ১৪২৫, ১৪২৬
YYYYb১৪২০ (বঙ্গাব্দ), ..., ১৪২৬ (বঙ্গাব্দ)
7.0.0

2 years ago

6.0.1

2 years ago

4.0.0

3 years ago

5.0.0

3 years ago

6.0.0

3 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.0.0

5 years ago

0.0.2

6 years ago

0.0.1

6 years ago