Nepali DateNepali DateBikram Sambat Date Engine
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

ParameterTypeRequiredDefaultDescription
startOfWeeknumberNo0Day 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 NepaliDate instance 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()); // 59

Custom 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)

Advertisement

On this page