Methods
date.isEqual()
Check whether two date instances share the exact same calendar date coordinates regardless of time.
The isEqual method checks whether the current NepaliDate instance shares the exact same Bikram Sambat year, month, and day coordinates as another date object, ignoring any differences in hours, minutes, seconds, or milliseconds.
Import
import { NepaliDate } from "nepali-date-library";Signature
isEqual(date: NepaliDate): boolean;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
date | NepaliDate | Yes | Target NepaliDate instance to compare against. |
Return Value
- Type:
boolean - Returns
trueifyear,month, anddayare identical; otherwise returnsfalse.
Behavior Note
Unlike isBefore() and isAfter(), which compare millisecond-level timestamps, isEqual() evaluates calendar dates only:
this.year === date.year && this.month === date.month && this.day === date.dayTwo instances created at different times of the same day will return true.
Examples
Comparing Calendar Dates
import { NepaliDate } from "nepali-date-library";
const date1 = new NepaliDate("2081-01-15");
const date2 = new NepaliDate(2081, 0, 15);
console.log(date1.isEqual(date2)); // trueTime Component Independence
import { NepaliDate } from "nepali-date-library";
const morning = new NepaliDate("2081-01-15").startOfDay();
const evening = new NepaliDate("2081-01-15").endOfDay();
console.log(morning.isEqual(evening)); // trueRelated
date.isSame(): Compare dates by specific calendar unit (year,month, orday).date.isBefore(): Millisecond-level chronological check.date.isAfter(): Millisecond-level chronological check.
Advertisement
date.isAfter()
Check whether the current date occurs chronologically after another specified date.
date.isSame()
Check whether two dates match across a specified granularity such as year, month, or day.