Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.startOfWeek()

Return a new NepaliDate instance set to the first day of the week on Sunday.

The startOfWeek method returns a new NepaliDate instance set to Sunday, the first day of the weekly cycle containing the current date. It serves as an anchor date for week based scheduling and calendar grids.


Import

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

Signature

startOfWeek(startOfWeek?: number): NepaliDate;

Parameters

ParameterTypeRequiredDefaultDescription
startOfWeeknumberNo0Day of week index (0-6), where 0 is Sunday and 1 is Monday.

Return Value

  • Type: NepaliDate
  • Returns a new NepaliDate instance set to the start of the week at midnight. 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 Start (Sunday)

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

// Suppose date falls on a Wednesday (day 3)
const date = new NepaliDate("2081-02-16");

const weekStart = date.startOfWeek();
console.log(weekStart.getDay()); // 0 (Sunday)
console.log(weekStart.getHours()); // 0
console.log(weekStart.format("YYYY-MM-DD"));

Custom Week Start (Monday)

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

const date = new NepaliDate("2081-02-16");

// Week starts on Monday (1)
const mondayStart = date.startOfWeek(1);
console.log(mondayStart.getDay()); // 1 (Monday)

Advertisement

On this page