Nepali DateNepali DateBikram Sambat Date Engine

Overview

Complete documentation and feature guide for the Nepali Date Library in Node.js and TypeScript applications.

The Nepali Date Library for Node.js provides a high performance toolkit with zero external dependencies for Bikram Sambat calendar operations. It handles bidirectional conversion between Bikram Sambat and Gregorian calendars, date arithmetic, custom string formatting, fiscal year calculations, and calendar grid generation for modern web applications and backend systems.


Installation

Install via your preferred package manager:

pnpm add nepali-date-library

Quick Start

import { NepaliDate, ADtoBS, BStoAD } from "nepali-date-library";

// 1. Current Nepali date
const today = new NepaliDate();
console.log(today.format("YYYY-MM-DD")); // e.g. "2081-06-29"

// 2. Parse a BS date
const event = new NepaliDate("2081-07-15");
console.log(event.format("DDDD, MMMM D, YYYY")); // "Friday, Kartik 15, 2081"

// 3. Convert to JavaScript Date (Gregorian AD)
const adDate = event.toJsDate();
console.log(adDate.toISOString()); // "2024-10-31T18:15:00.000Z"

// 4. Standalone conversion helpers
const bs = ADtoBS("2024-11-15"); // "2081-07-30"
const ad = BStoAD("2081-07-30"); // "2024-11-15"

Core Capabilities

  • Strict TypeScript Types: Fully typed with comprehensive IntelliSense and autocomplete.
  • Zero Runtime Dependencies: Ultra-lightweight footprint suitable for Node.js, React, Next.js, and edge workers.
  • Bidirectional Conversion: Accurate conversion between Gregorian (AD) and Bikram Sambat (BS) from 1976 to 2100 BS.
  • Date Arithmetic: Add and subtract days, months, and years with accurate month-day boundary clamping.
  • Fiscal Year Engine: Built-in calculation for Nepali fiscal years (Shrawan to Ashadh) and financial quarters.
  • Devanagari Localization: Native formatting with Nepali numerals (२०८१), month names (कार्तिक), and weekdays (शुक्रबार).

Package Details

SpecificationResource & Link
Package Namenepali-date-library
npm Registrynpmjs.com/package/nepali-date-library
GitHub RepositorySandipGhimire/Nepali-Date-Library-NodeJS
Download MetricsView Stats on npmjs.com
Runtime SupportNode.js 18+, Bun 1.0+, Deno, Modern Browsers
LicenseMIT
Advertisement

On this page