Nepali DateNepali DateBikram Sambat Date Engine
Date Converter

BStoAD()

Pure helper function to convert Bikram Sambat date strings into Gregorian calendar date strings.

The BStoAD function converts a Bikram Sambat date string into its equivalent Gregorian calendar date string. It validates the input Nepali date against verified historical calendar maps and returns a formatted Gregorian date string suitable for storage in standard SQL databases or transmission over web APIs.


Import

from nepali_date_library import BStoAD

Signature

def BStoAD(bsDate: str) -> str:

Parameters

ParameterTypeRequiredDescription
bsDatestrYesBikram Sambat date string formatted strictly as YYYY-MM-DD.

Return Value

  • Type: str
  • Format: YYYY-MM-DD representing the equivalent Gregorian calendar date.

Exceptions

Error MessageTrigger Condition
Invalid date format. Expected format: YYYY-MM-DDRaised if input string fails the regex validation ^\d{4}-\d{2}-\d{2}$.
Nepal year out of rangeRaised if the year is earlier than 1976 BS or later than 2100 BS.
Invalid Nepali monthRaised if the month number is not between 1 and 12.
Invalid Nepali dateRaised if the day number exceeds the actual days in that specific Nepali month.

Examples

Basic Conversion

from nepali_date_library import BStoAD

gregorian_date = BStoAD("2080-01-01")
print(gregorian_date) # "2023-04-14"

Storing in SQL Databases

user_input_bs = "2081-07-15"
database_ad_date = BStoAD(user_input_bs)
print(database_ad_date) # "2024-10-31"

Advertisement

On this page