getNepaliCalendarAfterAdditionOrSubtraction

fun getNepaliCalendarAfterAdditionOrSubtraction(year: Int, month: Int, dayOfMonth: Int, daysToAdjust: Int): CustomCalendar(source)

Adjusts a given Nepali date by adding or subtracting number of days.

This function calculates the resulting Nepali date after adjusting the provided year, month, and day by a given number of days (positive or negative). It handles all months and years calculations according to the day adjustment, ensuring correct calculation of Nepali calendar.

Return

A CustomCalendar instance representing the adjusted Nepali date.

Parameters

year

The Nepali year (e.g., 2081).

month

The Nepali month (1 to 12).

dayOfMonth

The Nepali day of the month (1 to 32, depending on the month).

daysToAdjust

The number of days to adjust by. Positive values will add days, and negative values will subtract days. i.e, 15, -20, 366, -454,etc.

Throws

if the provided date is invalid.

Example usage:

// Add 10 days to Nepali date 2081-03-15
val adjustedDate = getNepaliCalendarAfterAdditionOrSubtraction(2081, 3, 15, 10)
println(adjustedDate) // Output: CustomCalendar(year=2081, month=3, dayOfMonth=25, ...)

// Subtract 5 days from Nepali date 2081-03-15
val adjustedDate = getNepaliCalendarAfterAdditionOrSubtraction(2081, 3, 15, -5)
println(adjustedDate) // Output: CustomCalendar(year=2081, month=3, dayOfMonth=10, ...)

// Add 50 days, crossing over to the next month/year
val adjustedDate = getNepaliCalendarAfterAdditionOrSubtraction(2081, 11, 15, 50)
println(adjustedDate) // Output: CustomCalendar(year=2082, month=1, dayOfMonth=5, ...)