calendar
Provides a calendar system for Bikram Sambat (BS) dates.
This module offers functions to generate calendar data structures, providing day-by-day mapping between BS and AD dates. It includes methods to fetch data for specific months or entire years, and a monthcalendar function similar to the standard Python calendar module.
Examples
from bikram_sambat import bs_calendar, monthcalendar
# Generate day-by-day mapping of BS month to AD dates
bs_cal = bs_calendar(year=2080, month=1)
print(bs_cal.days[0].ad_full_date)
# >> 2023-04-14
# Convert the generated calendar datamodels directly to a Python dictionary
cal_dict = bs_cal.to_dict()
print(cal_dict["bs_year"])
# >> 2080
# Create a UI-friendly week-by-week matrix (Starting on Sunday)
matrix = monthcalendar(year=2080, month=1)
print(matrix[0])
# >> [0, 0, 0, 0, 0, 1, 2]
- class bikram_sambat.calendar.CalendarDayData(bs_year: int, bs_month: int, bs_day: int, ad_year: int, ad_month: int, ad_day: int, ad_full_date: str, week_day: int)[source]
Bases:
objectRepresents a single day in the calendar with both BS and AD dates.
- bs_year: int
- bs_month: int
- bs_day: int
- ad_year: int
- ad_month: int
- ad_day: int
- ad_full_date: str
- week_day: int
- class bikram_sambat.calendar.CalendarMonthData(bs_year: int, bs_month: int, ad_year: int, ad_month: int, days: List[CalendarDayData])[source]
Bases:
objectRepresents a month in the calendar.
- bs_year: int
- bs_month: int
- ad_year: int
- ad_month: int
- days: List[CalendarDayData]
- bikram_sambat.calendar.bs_calendar(year: int, month: int | None = None) CalendarMonthData | List[CalendarMonthData][source]
Generates calendar data for a given BS year and optional month.
If month is provided, returns data for that specific BS month. If month is None, returns a list of data for all 12 BS months.
- bikram_sambat.calendar.ad_calendar(year: int, month: int | None = None) CalendarMonthData | List[CalendarMonthData][source]
Generates calendar data for a given AD year and optional month.
If month is provided, returns data for that specific AD month. If month is None, returns a list of data for all 12 AD months.