Skip to content

Helper functions

A tree-shakeable, NepaliFunctions-compatible toolkit for BS↔AD math — usable without any picker. Convert a date below to see it work:

2083-04-03 BS (२०८३)
2026-07-19 AD · 31 days in month
Reference
AD2BS(date)AD Date → { year, month, day } BS
BS2AD(y, m, d)BS parts → AD Date
ConvertToUnicode(n)Digits → Devanagari (२०८१)
ConvertToNumber(s)Devanagari digits → ASCII
BS.GetCurrentDate()Today's BS date
BS.GetDaysInMonth(y, m)Days in a BS month
BS.GetMonthsInUnicode()Nepali month names
BS.ValidateDate(y, m, d)Is this a real BS date?
BS.IsBetweenDates(d, a, b)Range comparison
AD.GetDaysInMonth(y, m)Days in an AD month
AD.DatesDiff(a, b)Whole days between AD dates
AD.AddDays(d, n)Shift an AD date by n days
import { nepaliFunctions as NF } from 'nepali-datepicker-pro';

NF.AD2BS(new Date());              // → { year, month, day }
NF.BS2AD(2081, 4, 1);              // → Date (AD)
NF.BS.GetDaysInMonth(2081, 4);     // → 32
NF.ConvertToUnicode(2081);         // → '२०८१'

Usage

ts
import { nepaliFunctions as NF } from 'nepali-datepicker-pro';

NF.AD2BS(new Date());              // → { year, month, day }
NF.BS2AD(2081, 4, 1);              // → Date (AD)
NF.BS.GetDaysInMonth(2081, 4);     // → 32
NF.ConvertToUnicode(2081);         // → '२०८१'

Because the helpers are a plain object of pure functions, importing them pulls in the conversion engine and nothing else — no DOM code, no picker CSS.

Validity range

Conversions are validated against the official calendar for BS 1970–2100. Dates outside that window throw rather than returning an approximation, so a bad input surfaces at the call site instead of becoming a silently wrong date downstream.

See also

  • Migration — moving off window.NepaliFunctions

Released under the MIT License.