Nepali DateNepali DateBikram Sambat Date Engine
Static Methods

NepaliDate.get_calendar_days()

Static utility to generate a complete forty two cell calendar grid matrix for any month and year.

The get_calendar_days static method generates a complete forty two cell grid structure representing six rows of seven days for displaying a monthly calendar view. It includes trailing days from the previous month and leading days from the next month to fill out the matrix, simplifying the creation of date pickers and visual calendar components.


Import

from nepali_date_library import NepaliDate

Signature

@staticmethod
def get_calendar_days(year: int, month: int) -> Dict[str, Any]:

Parameters

ParameterTypeRequiredDescription
yearintYesFour digit Bikram Sambat year between 1976 and 2100.
monthintYesZero based month index from 0 (Baisakh) to 11 (Chaitra).

Return Value

  • Type: Dict[str, Any]
  • Structure:
    • "year": Bikram Sambat year.
    • "month": Month index.
    • "days": List of 42 cell dictionaries with keys:
      • "date": NepaliDate instance.
      • "isCurrentMonth": Boolean indicating if day belongs to requested month.
      • "day": Day integer.

Examples

from nepali_date_library import NepaliDate

# Generate grid matrix for Kartik 2081 BS (month index 6)
grid = NepaliDate.get_calendar_days(2081, 6)

print(f"Total cells: {len(grid['days'])}") # 42 cells

# Print each day in the calendar view
for cell in grid["days"]:
    status = "Current" if cell["isCurrentMonth"] else "Neighbor"
    print(f"Day {cell['day']} ({status})")

Advertisement

On this page