Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.daysInMonth()

Retrieve the total number of days in the current or specified Bikram Sambat month.

The daysInMonth method returns the total number of days present in the active month of the current NepaliDate instance, or for an explicitly provided year and month combination. Because Bikram Sambat month durations vary from 29 to 32 days depending on astronomical solar calculations, this method provides accurate month lengths.


Import

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

Signature

daysInMonth(year?: number, month?: number): number;

Parameters

ParameterTypeRequiredDefaultDescription
yearnumberNothis.yearBikram Sambat year (e.g. 2081).
monthnumberNothis.monthZero-indexed month (0-11, where 0 is Baisakh and 11 is Chaitra).

Return Value

  • Type: number
  • The number of days in the specified month (typically between 29 and 32 days).

Exceptions

Throws an Error if month is explicitly provided and is less than 0 or greater than 11:

"Invalid month index, must be between 0-11"

Examples

Querying the Current Instance Month

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

// 2081 Baisakh
const date = new NepaliDate(2081, 0, 15);
console.log(date.daysInMonth()); // 31

Querying an Arbitrary Year and Month

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

const date = new NepaliDate();

// Querying Jestha 2081 (month index 1)
const jesthaDays = date.daysInMonth(2081, 1);
console.log(jesthaDays); // 32

// Querying Chaitra 2080 (month index 11)
const chaitraDays = date.daysInMonth(2080, 11);
console.log(chaitraDays); // 30

Advertisement

On this page