Methods
date.set_month()
Set the Bikram Sambat month index on a NepaliDate instance with automatic day clamping.
The set_month method updates the Bikram Sambat month for the current NepaliDate instance using a zero based month index from 0 for Baisakh to 11 for Chaitra. If the current day exceeds the total days in the destination month, the day is automatically clamped to the final valid day of that month.
Import
from nepali_date_library import NepaliDateSignature
def set_month(self, month: int) -> None:Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
month | int | Yes | Target zero based month index from 0 to 11. |
Return Value
- Type:
None - Note: Mutates the current instance in place.
Example
from nepali_date_library import NepaliDate
date = NepaliDate("2081-01-31")
# Change to month index 1 (Jestha)
date.set_month(1)
print(date.format("YYYY-MM-DD"))Related
date.get_month(): Retrieve month index.date.add_months(): Add or subtract months.
Advertisement
date.set_year()
Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range.
date.set_date()
Set the day of the month on a NepaliDate instance and recalculate its timestamp.