Skip to content

sh4hids/bangla-calendar

Repository files navigation

📅 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

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 ā§§ā§Ēā§¨ā§Ļ (āĻŦāĻ™ā§āĻ—āĻžāĻŦā§āĻĻ), ..., ā§§ā§Ēā§¨ā§Ŧ (āĻŦāĻ™ā§āĻ—āĻžāĻŦā§āĻĻ)