Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.startOfYear()

Return a new NepaliDate instance set to the first day of the Bikram Sambat year on 1 Baisakh.

The startOfYear method returns a new NepaliDate instance set to 1 Baisakh, the first day of the Bikram Sambat calendar year. This is useful for year to date financial tracking and annual summary reports.


Import

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

Signature

startOfYear(): NepaliDate;

Parameters

This method does not take any parameters.


Return Value

  • Type: NepaliDate
  • Returns a new NepaliDate set to 1st Baisakh of the current year. The original instance is not modified.

Examples

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

// Any date within 2081 BS
const date = new NepaliDate("2081-08-15");

const newYear = date.startOfYear();
console.log(newYear.format("YYYY-MM-DD")); // "2081-01-01"
console.log(newYear.getMonth()); // 0 (Baisakh)
console.log(newYear.getDate()); // 1

Year-to-Date Calculations

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

const today = new NepaliDate("2081-06-15");
const yearStart = today.startOfYear();

const daysElapsed = today.diff(yearStart, "day");
console.log(daysElapsed); // Number of days since start of the year

Advertisement

On this page