Framework-agnostic TypeScript library for Bikram Sambat (Nepali) date operations, number conversion, calendar utilities, location data, validation, and currency formatting.
1npm install @nepali-utils/coreConvert between Bikram Sambat and Gregorian (AD) dates with high accuracy for dates from BS 2000 to BS 2100 (AD 1943–2043).
12345678910import { bsToAd, adToBs, getTodayBs } from "@nepali-utils/core" const today = getTodayBs()// → { year: 2081, month: 5, day: 15 } const adDate = bsToAd(today)// → Date (JavaScript Date object) const backToBs = adToBs(adDate)// → { year: 2081, month: 5, day: 15 }Compare BS dates with equality and ordering checks.
12345import { isSameBsDate, isBeforeBsDate, isAfterBsDate } from "@nepali-utils/core" isSameBsDate(date1, date2) // → booleanisBeforeBsDate(date1, date2) // → booleanisAfterBsDate(date1, date2) // → booleanFormat BS dates with custom patterns in English or Nepali (Devanagari).
12345678910import { formatBsDate, toNepaliNumber, parseNepaliNumber } from "@nepali-utils/core" formatBsDate(date, "en", { pattern: "YYYY MMMM DD" })// → "2081 Bhadra 15" formatBsDate(date, "ne", { pattern: "YYYY MMMM DD" })// → "२०८१ भदौ १५" toNepaliNumber(2081) // → "२०८१"parseNepaliNumber("२०८१") // → 2081Get calendar grid data, month details, and year ranges for building custom calendar UIs.
1234567import { generateCalendarGrid, getDaysInBsMonth, MONTHS } from "@nepali-utils/core" const grid = generateCalendarGrid(2081, 5)// Returns array of CalendarDay objects for rendering getDaysInBsMonth(2081, 5) // → number of days in Bhadra 2081MONTHS.ne // → ["बैशाख", "जेष्ठ", ...]Complete dataset for Nepal's provinces, districts, municipalities, and wards with utility functions for lookups.
123456789import { provinces, getProvinceById, districts, getDistrictsByProvince, municipalities, getMunicipalitiesByDistrict,} from "@nepali-utils/core" provinces // → all 7 provincesgetProvinceById(1) // → ProvinceInfogetDistrictsByProvince(1) // → districts in province 1Validate Nepali phone numbers with carrier detection.
1234567import { isValidNepaliMobile, getPhoneType } from "@nepali-utils/core" isValidNepaliMobile("9841234567") // → truegetPhoneType("9841234567") // → "NTC" formatNepaliPhone("9841234567")// → "984-1234567"Format amounts in Nepali currency and convert numbers to Nepali words.
1234567import { formatNepaliCurrency, toNepaliWords } from "@nepali-utils/core" formatNepaliCurrency(12345.67)// → "रु १२,३४५.६७" toNepaliWords(12345)// → "बाह्र हजार तीन सय पैंतालीस"