Methods
date.endOfWeek()
Return a new NepaliDate instance set to the final day of the current week on Saturday.
The endOfWeek method produces a new NepaliDate instance representing the last day of the week containing the current date. In standard Nepali calendar practice, Saturday is regarded as the final day of the weekly cycle.
Import
import { NepaliDate } from "nepali-date-library";Signature
endOfWeek(startOfWeek?: number): NepaliDate;Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
startOfWeek | number | No | 0 | Day of week index (0-6) that defines when the week begins. By default, 0 (Sunday) is the start, making Saturday (6) the end. |
Return Value
- Type:
NepaliDate - Returns a new
NepaliDateinstance set to the end of the final day of the week (23:59:59.999). The original instance is not modified.
Exceptions
Throws an Error if startOfWeek is not an integer between 0 and 6:
"startOfWeek must be an integer between 0 and 6"Examples
Default Week End (Saturday 23:59:59)
import { NepaliDate } from "nepali-date-library";
const date = new NepaliDate("2081-02-16");
const weekEnd = date.endOfWeek();
console.log(weekEnd.getDay()); // 6 (Saturday)
console.log(weekEnd.getHours()); // 23
console.log(weekEnd.getMinutes()); // 59Custom Week Ending on Sunday
import { NepaliDate } from "nepali-date-library";
const date = new NepaliDate("2081-02-16");
// Week starts on Monday (1), meaning it ends on Sunday (0)
const weekEnd = date.endOfWeek(1);
console.log(weekEnd.getDay()); // 0 (Sunday)Related
date.startOfWeek(): Return the beginning of the week.date.endOfDay(): Return end of the day.date.getDay(): Get current day of week index (0-6).
Advertisement
date.startOfWeek()
Return a new NepaliDate instance set to the first day of the week on Sunday.
date.startOfMonth()
Return a new NepaliDate instance set to the first day of the current Bikram Sambat month.