Skip to content

nepali-calendar-engine


nepali-calendar-engine / toBS

Function: toBS()

toBS(adDate): BSDate

Defined in: converter/ad-to-bs.ts:22

Converts a JavaScript Date (Gregorian/AD) to a Bikram Sambat date.

The conversion reads UTC date components from the input Date, making it timezone-safe regardless of how the Date was constructed.

Complexity: O(log n) — binary search over yearDayOffsets to find the year, then O(1) month lookup. n = 91 (years in dataset).

Throws RangeError for dates outside the supported range.

Parameters

adDate

Date

Returns

BSDate