Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@sbmdkl/nepali-date-converter

sbmdkl1.6kMIT2.0.4TypeScript support: included

A javascript package to convert nepali date BS (Bikram Sambat) to AD and vice-versa, calcuate age from nepali date (BS)

nepali age calculator, BS age, nepali-date-converter, nepali-date, english-to-nepali-date, AD-BS converter, BS-AD converter, ad-to-bs, nepali to english date, english to nepali date

readme

@sbmdkl/nepali-date-converter

NPM JavaScript Style Guide

A javascript package to convert nepali date BS (Bikram Sambat) to AD and vice-versa. Also include a feature to calculate age in nepali date. Demo.

Installation

npm install @sbmdkl/nepali-date-converter

Usage

const { adToBs, bsToAd, calculateAge } = require('@sbmdkl/nepali-date-converter');
try {
    const bsDate = adToBs('2078-03-05');
    console.log(bsDate);
    // to calculate age
    const myAge = calculateAge('2070-10-10');
    console.log(myAge);
} catch (e) {
    console.log(e.message);
}

Available Methods

adToBs('YYYY-MM-DD') - convert AD to BS date
bsToAd('YYYY-MM-DD') - convert BS to AD date
calculateAge('YYYY-MM-DD') - calculate age from BS date.

dateFormat

Format the date to provide various output based on format string

YYYY - 4 digit of year (2078)
MM   - month number with 0 padding - (01-12)
DD   - Day of Month with zero padding (01-32)

Date Range

Date convert will works between these Date Range:

Date Range for English Date : 1921 AD to 2040 AD

Date Range for Nepali Date : 1978 BS to 2099 BS

License

MIT © Shubham Dhakal