Methods
date.getWeeksInMonth()
Calculate the number of calendar week rows required to render the current month in a grid.
The getWeeksInMonth method computes the total number of seven day week rows required to display the entire month in a standard calendar grid. Depending on which weekday the month starts on and how many days it contains, the returned count is usually five or six rows.
Import
import { NepaliDate } from "nepali-date-library";Signature
getWeeksInMonth(): number;Parameters
This method does not take any parameters.
Return Value
- Type:
number - The number of calendar week rows needed (typically
5or6).
Formula
The calculation evaluates the weekday offset of the 1st of the month added to the month's total days, divided by 7:
Math.ceil((firstDayOfWeek + totalDays) / 7)Examples
Sizing UI Calendar Views
import { NepaliDate } from "nepali-date-library";
const date = new NepaliDate("2081-01-15");
const rowCount = date.getWeeksInMonth();
console.log(`Calendar requires ${rowCount} week rows.`);Related
NepaliDate.getCalendarDays(): Generate calendar matrix with leading and trailing days.date.daysInMonth(): Total number of days in the month.
Advertisement
date.daysInMonth()
Retrieve the total number of days in the current or specified Bikram Sambat month.
date.getCurrentQuarter()
Return the standard Bikram Sambat calendar quarter number from one to four for the current date.