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 🙏

© 2024 – Pkg Stats / Ryan Hefner

date-bengali-revised

v2.0.2

Published

Revised Bengali Calendar

Downloads

646,670

Readme

date-bengali-revised

Revised Bengali Calendar

NPM version Build Status

Revised Bengali Calendar calculations with conversion from/ to Gregorian Date.
The revised version of the Bengali calendar was officially adopted in Bangladesh in 1987.

The module supports:

  • conversion from Gregorian Date to Bengali Date and vice versa
  • conversion from javascript Date object to Bengali Date and vice versa
  • formatting

Credits to Nuhil Mehdy for his project bangla-calendar. The inital algorithm and the bengali names were taken from there. Thanks.

Table of Contents

Usage

Construct a new Bengali Date

Parameters

year: {Number|String}, bengali year in bengal or latin digits
month: {Number|String}, bengali month
day: {Number|String}, bengali day

// ES5
import Calendar from 'date-bengali-revised'
// CommonJs
const Calendar = require('date-bengali-revised').default

let cal = new Calendar(1425, 1, 1)
//> { year: 1425, month: 1, day: 1}

// with bengali digits
cal = new Calendar('১৪২৫', '১', '১')
//> { year: 1425, month: 1, day: 1}

// with bengali month name
cal = new Calendar('১৪২৫', 'বৈশাখ', '১')
//> { year: 1425, month: 1, day: 1}

from Gregorian Date

Parameters

year: {Number}, gregorian year
month: {Number}, gregorian month
day: {Number}, gregorian day

Returns: this for chaining

import Calendar from 'date-bengali-revised'
let cal = new Calendar()
cal.fromGregorian(2018, 4, 14)
//> { year: 1425, month: 1, day: 1}

to Gregorian Date

Convert Bengali Date back to Gregorian Date

Returns: {Object} {year, month, day} as gregorian date

let cal = new Calendar(1425, 1, 1)
let gdate = cal.toGregorian()
//> { year: 2018, month: 4, day: 14 }

from Date

Calculate bengali calendar date from javascript Date object

Parameters

date: {Date} - javascript Date object

Returns: this for chaining

let cal = new Calendar()
let date = new Date('2018-04-14T06:00:00Z')
cal.fromDate(date)
//> { year: 1425, month: 1, day: 1}

to Date

Returns: {Date} - javascript Date object

let cal = new Calendar(1425, 1, 1)
let date = cal.toDate(date).toISOString()
//> '2018-04-14T06:00:00Z'

formatting

Parameters

formatStr: {String} - formatting string

| Input | Description | | ----- | ------------ | | Y | Year with any number of digits and sign | | Q | Season Name | | M | Month number | | MMMM | Month name | | D | Day of month | | dddd | Day name |

Returns: {String} formatted date

let cal = new Calendar(1425, 1, 1)
cal.format()
//> '১ ১, ১৪২৫'
cal.format('dddd D MMMM, Y [Q]')
//> 'শনিবার ১ বৈশাখ, ১৪২৫ [গ্রীষ্ম]'

Contribution and License Agreement

If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work or correctly attributed with the source of its origin and License.

License

Copyright (c) 2018-present commenthol (MIT License)

See LICENSE for more info.

References