Navigation Menu

Skip to content

sh4hids/bangla-calendar

Repository files navigation

馃搮 bangla-calendar StarsLicenseGitHub 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

Parameter Type Example
date JavaScript date new Date('August 16 2019 06:22:03')
options object { 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

Parameter Type Example
date JavaScript date new Date('August 16 2019 06:22:03')
options object { 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

Parameter Type Example
date JavaScript date new Date('August 16 2019 06:22:03')
options object { 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

Parameter Type Example
date JavaScript date new Date('August 16 2019 06:22:03')
options object { 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

Parameter Type Example
date JavaScript date new Date('August 16 2019 06:22:03')
options object { format: 'YYYY', calculationMethod: 'BD' }

Options

calculationMethod (string)

Country Token
Bangladesh BD
India IN

format (string)

Unit Token Result examples
Day D 唰, 唰, 唰, 唰, ..., 唰┼Е, 唰┼Ё
DD 唰︵Ё, 唰︵Ж, 唰︵З, 唰︵И, ..., 唰┼Е,
Weekday eee 唳多唳曕唳, 唳多Θ唳, 唳班Μ唳, ..., 唳唳灌Ω唰嵿Κ唳む
eeee 唳多唳曕唳班Μ唳距Π, 唳多Θ唳苦Μ唳距Π, 唳班Μ唳苦Μ唳距Π, ..., 唳唳灌Ω唰嵿Κ唳む唳唳
Month M 唰, 唰, 唰, 唰, ..., 唰оЁ, 唰оЖ
MM 唰︵Ё, 唰︵Ж, 唰︵З, 唰︵И, ..., 唰оЁ, 唰оЖ
MMMM 唳唳多唳, 唳溹唳唳粪唳, 唳嗋Ψ唳距Β唳, 唳多唳班唳Γ, ..., 唳唳侧唳椸唳, 唳氞唳む唳
Year YY 唰ㄠЕ, 唰ㄠЁ, 唰ㄠЖ, ..., 唰ㄠЙ, 唰ㄠК
YYYY 唰оИ唰ㄠЕ, 唰оИ唰ㄠЁ, 唰оИ唰ㄠЖ, ..., 唰оИ唰ㄠЙ, 唰оИ唰ㄠК
YYYYb 唰оИ唰ㄠЕ (唳唰嵿唳距Μ唰嵿Ζ), ..., 唰оИ唰ㄠК (唳唰嵿唳距Μ唰嵿Ζ)