UNPKG

bk-ad

Version:

Utility library to convert date in AD to Nepali date BS (Bikram sambat) and vice versa.

62 lines (42 loc) 987 B
# Bikram Sambat Utility library to convert date in AD (Gregorian) to Nepali date format BS (Bikram sambat) and vice versa. [![Version](https://img.shields.io/npm/v/bk-ad?logo=npm)](https://www.npmjs.com/package/bk-ad) [![Twitter Follow](https://img.shields.io/twitter/follow/PuncozNepal?label=Follow&style=social)](https://twitter.com/PuncozNepal) ## Installation Using NPM: ``` npm i bk-ad ``` or, using Yarn: ``` yarn add bk-ad ``` ## Usage ### Import package Using ES6 `import`: ``` import BikramSambat, {ADToBS, BSToAD} from "bk-ad" ``` or, using commonJS `require` ``` const BS = require('bk-ad') BS.ADToBS("2019-08-25") ``` #### 1. BS to AD conversion Syntax: `BSToAD(date: string): string` ``` BSToAD("2076-05-08") // "2019-08-25" ``` or, ``` new BikramSambat('2076-05-08', 'BS').toAD() ``` #### 2. AD to BS conversion Syntax: `ADToBS(date: Date | string): string` ``` ADToBS("2019-08-25") // "2076-05-08" ``` or, ``` new BikramSambat('2019-08-25').toBS() ```