Methods
date.endOfYear()
Return a new NepaliDate instance set to the final day of the Bikram Sambat year on the last day of Chaitra.
The endOfYear method returns a new NepaliDate instance set to the closing day of the current Bikram Sambat calendar year. This corresponds to the final day of Chaitra, which is commonly needed for annual reconciliations and fiscal year preparations.
Import
import { NepaliDate } from "nepali-date-library";Signature
endOfYear(): NepaliDate;Parameters
This method does not take any parameters.
Return Value
- Type:
NepaliDate - Returns a new
NepaliDateset to the last day of Chaitra for the given year at23:59:59.999. The original instance is not modified.
Examples
Getting the Final Day of the Calendar Year
import { NepaliDate } from "nepali-date-library";
const date = new NepaliDate("2081-03-15");
const yearEnd = date.endOfYear();
console.log(yearEnd.format("YYYY-MM-DD")); // "2081-12-30"
console.log(yearEnd.getMonth()); // 11 (Chaitra)
console.log(yearEnd.getHours()); // 23
console.log(yearEnd.getMinutes()); // 59
console.log(yearEnd.getSeconds()); // 59Full Calendar Year Span
import { NepaliDate } from "nepali-date-library";
const year = 2081;
const start = new NepaliDate(year, 0, 1).startOfDay();
const end = new NepaliDate(year, 0, 1).endOfYear();
console.log(`Year ${year} spans from ${start.format("YYYY-MM-DD")} to ${end.format("YYYY-MM-DD")}`);Related
date.startOfYear(): Return the first day of the Bikram Sambat year.date.endOfMonth(): Return the final day of the current month.date.isLeapYear(): Check if the year has 366 days.
Advertisement
date.startOfYear()
Return a new NepaliDate instance set to the first day of the Bikram Sambat year on 1 Baisakh.
date.isBefore()
Check whether the current date occurs chronologically before another specified date.