Nepali DateNepali DateBikram Sambat Date Engine
Date Converter

Date Converter Guide

Comprehensive guide to converting dates between Gregorian and Bikram Sambat calendar systems using standalone helper functions.

The date converter utilities provide pure standalone functions for converting date strings directly between the Gregorian calendar and the Bikram Sambat calendar. These functions operate without creating full class instances, making them suitable for high throughput batch processing, database migrations, and backend service integration.


Available Functions

The library exports two primary conversion functions:

  • ADtoBS(adDate: str): Converts a Gregorian calendar date string to a Bikram Sambat date string.
  • BStoAD(bsDate: str): Converts a Bikram Sambat date string to a Gregorian calendar date string.

Format Requirements

Both functions require strict ISO formatted date strings:

YYYY-MM-DD
  • Four digit year (YYYY)
  • Two digit month with leading zero (MM)
  • Two digit day with leading zero (DD)

Comparison: Helper Functions vs NepaliDate Class

RequirementUse ADtoBS and BStoADUse NepaliDate Class
Fast string conversionRecommendedOptional
Database pipelines and ETLRecommendedOptional
Date arithmetic (add_days, diff)NoRecommended
Custom token formattingNoRecommended
Calendar boundary calculationsNoRecommended
Fiscal year operationsNoRecommended

Quick Example

from nepali_date_library import ADtoBS, BStoAD

# Gregorian to Bikram Sambat
bs = ADtoBS("2024-11-15")
print(bs) # "2081-07-30"

# Bikram Sambat to Gregorian
ad = BStoAD("2081-07-30")
print(ad) # "2024-11-15"
Advertisement

On this page