Nepali DateNepali DateBikram Sambat Date Engine
Constants

NUMBER_NP

Array containing Devanagari numeral glyphs for digits zero through nine used for Nepali number localization.

The NUMBER_NP constant is an array containing the ten Devanagari numeral characters representing digits 0 through 9 in Nepali script. It provides a direct lookup table for formatting numbers, years, dates, and currency values into native Devanagari script for Nepali language interfaces.


Import

import { NUMBER_NP } from "nepali-date-library";

Value

export const NUMBER_NP = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"];

Index Mapping

IndexCharacterUnicode Codepoint
0"०"U+0966
1"१"U+0967
2"२"U+0968
3"३"U+0969
4"४"U+096A
5"५"U+096B
6"६"U+096C
7"७"U+096D
8"८"U+096E
9"९"U+096F

Examples

Converting Arabic Digits to Devanagari

import { NUMBER_NP } from "nepali-date-library";

function toNepaliDigits(num: number | string): string {
  return String(num)
    .split("")
    .map((ch) => {
      const code = ch.charCodeAt(0) - 48;
      return code >= 0 && code <= 9 ? NUMBER_NP[code] : ch;
    })
    .join("");
}

console.log(toNepaliDigits(2081)); // "२०८१"
console.log(toNepaliDigits("2081-01-25")); // "२०८१-०१-२५"

  • date.format(): Format dates with lowercase tokens (yyyy, mm, dd).
Advertisement

On this page