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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ad-bs-converter

v0.6.0

Published

Convert Bikram Sambat (BS) dates to Anno Domini (AD) and vice-versa. TypeScript, ESM and CommonJS.

Readme

ad-bs-converter npm version CI

Convert Bikram Sambat (BS, the Nepali calendar) dates to Anno Domini (AD, Gregorian) and vice-versa.

Written in TypeScript, published as both ESM and CommonJS with bundled type declarations. Requires Node 22 or newer (CI runs on Node 22, 24 and 26; .nvmrc points at 26) and works in any modern browser bundler.

If you are looking for an ad-bs converter for Python, check out ad-bs-converter.py.

Installation

npm install ad-bs-converter

Usage

// ESM / TypeScript
import { ad2bs, bs2ad } from 'ad-bs-converter';

// CommonJS
const { ad2bs, bs2ad } = require('ad-bs-converter');
console.log(ad2bs('1990/8/10'));
console.log(bs2ad('2047/4/26'));

outputs

{
  ne: {
    year: '२०४७',
    month: '४',
    day: '२६',
    strMonth: 'श्रावण',
    strShortMonth: 'श्रा',
    dayOfWeek: '५',
    strDayOfWeek: 'शुक्रवार',
    strShortDayOfWeek: 'शुक्र',
    strMinDayOfWeek: 'शु',
    totalDaysInMonth: '३२'
  },
  en: {
    year: 2047,
    month: 4,
    day: 26,
    strMonth: 'Shrawan',
    strShortMonth: 'Shra',
    dayOfWeek: 5,
    strDayOfWeek: 'Shukrabaar',
    strShortDayOfWeek: 'Shukra',
    strMinDayOfWeek: 'Shu',
    totalDaysInMonth: 32
  }
}
{
  year: 1990,
  month: 8,
  strMonth: 'August',
  strShortMonth: 'Aug',
  day: 10,
  dayOfWeek: 5,
  strDayOfWeek: 'Friday',
  strShortDayOfWeek: 'Fri'
}

Accepted inputs

Both functions accept a "yyyy/mm/dd" string (a - separator and leading zeros are fine) or a { year, month, day } object. ad2bs additionally accepts a JavaScript Date, which is read in the local time zone (getFullYear(), getMonth(), getDate()).

ad2bs('2026-11-11');
ad2bs({ year: 2026, month: 11, day: 11 });
ad2bs(new Date(2026, 10, 11));

bs2ad('2083/07/25');
bs2ad({ year: 2083, month: 7, day: 25 });

Months and days are always 1-based. dayOfWeek is 0 for Sunday through 6 for Saturday.

Errors

Malformed input, impossible dates (for example 2083/7/31, since Kartik 2083 has 30 days) and dates outside the supported range throw a RangeError with a descriptive message.

try {
  ad2bs('1900/1/1');
} catch (error) {
  // RangeError: AD date 1900/1/1 is outside the supported range 1918/4/13 - 2143/4/18
}

Supported range

import { SUPPORTED_RANGE } from 'ad-bs-converter';

SUPPORTED_RANGE.bs; // { start: { year: 1975, month: 1, day: 1 }, end: { year: 2199, month: 12, day: 30 } }
SUPPORTED_RANGE.ad; // { start: { year: 1918, month: 4, day: 13 }, end: { year: 2143, month: 4, day: 18 } }

The calendar table lives in src/data.ts and is also exported as CALENDAR_DATA (with MIN_BS_YEAR / MAX_BS_YEAR) for anyone who needs the raw month lengths.

A note on data accuracy

The Bikram Sambat calendar is not computed from a formula: month lengths are published by Nepal's Panchanga Nirnayak Samiti year by year. This library therefore ships a lookup table.

  • 1978 - 2090 BS: considered reliable. Every day in 2000 - 2090 BS is cross-checked in CI against the independent nepali-date-converter table with no disagreements (see test/crosscheck.test.ts).
  • 2082 and 2083 BS were corrected in v0.6.0; earlier releases carried provisional 2017-era predictions that were off by a day in the second half of those years (see the changelog).
  • 2004, 2062 and 2087 BS: PR #11 (2024, never published to npm) fixed 2081 but also rewrote these three rows to values that match no reference library. v0.6.0 restores the original rows, which agree with both nepali-date-converter and @remotemerge/nepali-date-converter.
  • 2091 BS and later are provisional. No official data exists yet and different sources disagree; the rows are kept so conversions keep working but they may change in a future release.

If you spot a discrepancy, please open an issue with the source you are comparing against.

TypeScript

All inputs and outputs are typed:

import type {
  AdDate,
  AdDateInput,
  BsDate,
  BsDateInput,
  DateParts,
  SupportedRange,
} from 'ad-bs-converter';

Development

npm install
npm run typecheck   # tsc --noEmit
npm run lint        # eslint + prettier --check
npm test            # vitest (unit, round-trip and cross-check suites)
npm run build       # tsup -> dist/ (ESM + CJS + .d.ts)
npm run smoke       # require()/import the built package

License

ISC