Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.add_months()

Add or subtract months to a NepaliDate instance while adjusting for variable month lengths.

The add_months method advances or rewinds the current NepaliDate instance by a specified number of months. If the current day of the month exceeds the total days available in the destination month, the method automatically clamps the day to the final valid day of that month to ensure calendar consistency.


Import

from nepali_date_library import NepaliDate

Signature

def add_months(self, months: int) -> NepaliDate:

Parameters

ParameterTypeRequiredDescription
monthsintYesPositive or negative integer of months to add.

Return Value

  • Type: NepaliDate
  • Description: Returns self after mutation.

Example

from nepali_date_library import NepaliDate

date = NepaliDate("2081-01-15")
date.add_months(6)
print(date.format("YYYY-MM-DD")) # "2081-07-15"

Advertisement

On this page