This package provides utility functions to convert dates from AD (Gregorian) to BS (Bikram Sambat) and vice versa. It is especially useful for handling date conversions between the two widely used calendar systems in Nepal.
This DEVELOPER_GUIDE.md file provides a structured, technical overview for developers working with or contributing to the ad-bs-converter
package.
To install the package, run:
npm i ad-bs-converter
You can import the functions using either ES6 modules or CommonJS:
import { adToBS, bsToAD } from "ad-bs-converter";
const { adToBS, bsToAD } = require("ad-bs-converter");
bsToAD("2053-06-25"); // Returns {year:1996, month:10, day:11}
adToBS("1996-10-11"); // Returns {year:2053, month:06, day:25}
String
Provide a valid date string. The current supported formats are:
YYYY/MM/DD
YYYY-MM-DD
YYYY MM DD
DD/MM/YYYY
DD-MM-YYYY
DD MM YYYY
Example
bsToAD("2051/02/01"); // YYYY/MM/DD
bsToAD("2051-02-01");
bsToAD("2051 02 01");
bsToAD("01/02/2051"); // DD/MM/YYYY
bsToAD("01-02-2051");
bsToAD("01 02 2051");
Number
The number value represents the UTC timestamp that will be converted to Nepali date.
Note: this is only available in
adToBs
function.
Example:
adToBs(1589638162879);
Empty Value
If no values are provided, the current day date will be returned.
adToBS(); // will return the current bs date
bsToAD(); // will return the current ad date