An utility library for converting English numerals and dates to Bengali
TriptoAfsin
Posted on February 26, 2024
Made in 🇧🇩(Bangladesh) with 💖
Description
bang-utils is a lightweight utility library for converting English numerals and dates to Bengali in TypeScript/ JavaScript. It provides functions to convert numbers, dates, and months from English to Bengali script.
Features -
- Full TypeScript Support
- English Number to Bangla Number(21.21 -> ২১.২১)
- English Date to Bangla Date(2-5-2024 -> ৫ ফেব্রুয়ারি, ২০২৪)
- English Time to Bangla Time (15:48 -> দুপুর ৩ টা ৪৮ মিনিট)
- English Number to Bangla In Words(50.25 -> পঞ্চাশ দশমিক দুই পাঁচ)
- Currency Number to Bangla Currency(125.58 -> ১২৫ টাকা ৫৮ পয়সা)
Installation
You can install bang-utils via npm or yarn:
npm install bang-utils
or
yarn add bang-utils
Usage
Importing
You can import the functions from bang-utils using ES6 import syntax:
import {
numBang,
dateBang,
monthBang,
numToBanglaWords,
dayBang,
currencyToBang,
timeBang,
} from "bang-utils";
Converting English Numerals to Bengali
console.log("number: ", numBang(21)); // Output: number: ২১
console.log("decimal number: ", numBang(21.21)); // Output: decimal number: ২১.২১
Converting Dates to Bengali
console.log("month: ", monthBang("2024-05-02")); // Output: month: মে
console.log("day: ", dayBang("2024-02-26")); //day: সোমবার
console.log("date: ", dateBang("2-5-2024", ",", "D M, YYYY")); // Output: date: ৫ ফেব্রুয়ারি, ২০২৪
Converting Numbers to Bengali Words
console.log("to Bangla words: ", numToBanglaWords(50.25)); // Output: to Bangla words: পঞ্চাশ দশমিক দুই পাঁচ
Converting Currency Numbers to Bengali Currency
console.log("currency: ", currencyToBang(50)); //currency: ৫০ টাকা
console.log("currency: ", currencyToBang(125.58)); //currency: ১২৫ টাকা ৫৮ পয়সা
Converting Date Time to Bengali Time
console.log("detailed time: ", timeBang(new Date())); //দুপুর ৩ টা ৪৮ মিনিট
console.log("normal time: ", timeBang(new Date(), "normal")); // দুপুর ৩.৫০ মিনিট
console.log("short time: ", timeBang(new Date(), "short")); //৩.৫০ মিনিট
Inspirations & Credits
The numToBanglaWords()
was based on a open source project by MAHMUDUL HASSAN named number-to-bengali-words
📌 Github : https://github.com/TriptoAfsin/bang-utils
📌 NPM: https://www.npmjs.com/package/bang-utils?activeTab=readme
💖 💪 🙅 🚩
TriptoAfsin
Posted on February 26, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
javascript An utility library for converting English numerals and dates to Bengali
February 26, 2024