Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.addDays()

Add or subtract a specified number of days to a NepaliDate instance with automatic month and year rollover.

The addDays method modifies the current NepaliDate instance by adding or subtracting a given integer number of days. It automatically handles variable Bikram Sambat month day counts, transitions across month boundaries, and advances or decrements the year when needed.


Import

import { NepaliDate } from "nepali-date-library";

Signature

addDays(days: number): NepaliDate;

Parameters

ParameterTypeRequiredDescription
daysnumberYesInteger number of days to add (positive) or subtract (negative).

Return Value

  • Type: NepaliDate
  • Returns a new NepaliDate instance with the specified days added or subtracted. The original instance is not modified.

Examples

Adding Days Across Month Boundaries

import { NepaliDate } from "nepali-date-library";

// 2081 Baisakh 25 (Baisakh 2081 has 31 days)
const date = new NepaliDate("2081-01-25");

const next = date.addDays(10);
console.log(next.format("YYYY-MM-DD")); // "2081-02-04" (4 Jestha)

Subtracting Days Across Year Boundaries

import { NepaliDate } from "nepali-date-library";

// 2081 Baisakh 02
const date = new NepaliDate("2081-01-02");

const prev = date.addDays(-5);
console.log(prev.format("YYYY-MM-DD")); // "2080-12-28" (28 Chaitra 2080)

Method Chaining

import { NepaliDate } from "nepali-date-library";

const date = new NepaliDate("2081-01-01")
  .addDays(15)
  .addDays(5);

console.log(date.format("YYYY-MM-DD")); // "2081-01-21"

Advertisement

On this page