Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.add_years()

Add or subtract years to a NepaliDate instance while preserving month and day values.

The add_years method adds or subtracts a specified number of years to the current NepaliDate instance. It recalculates the underlying timestamp while retaining the month and day coordinates, adjusting the day number if the target year has fewer days in that specific month.


Import

from nepali_date_library import NepaliDate

Signature

def add_years(self, years: int) -> NepaliDate:

Parameters

ParameterTypeRequiredDescription
yearsintYesNumber of years to advance or rewind.

Return Value

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

Example

from nepali_date_library import NepaliDate

date = NepaliDate("2075-01-01")
date.add_years(5)
print(date.format("YYYY-MM-DD")) # "2080-01-01"

Advertisement

On this page