Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.setYear()

Set the Bikram Sambat year on a NepaliDate instance within the supported calendar range.

The setYear method updates the four digit Bikram Sambat year on the current NepaliDate instance and adjusts the timestamp accordingly. The target year must fall within the supported range between 1976 and 2100 BS.


Import

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

Signature

setYear(year: number): void;

Parameters

ParameterTypeRequiredDescription
yearnumberYes4-digit Bikram Sambat year (1976 to 2100).

Return Value

  • Type: void
  • Mutates the current NepaliDate instance in place.

Exceptions

Error MessageTrigger Condition
Nepal year out of rangeThrown if year is earlier than 1976 BS or later than 2100 BS.

Example

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

const date = new NepaliDate("2080-01-01");
date.setYear(2082);

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

Advertisement

On this page