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

ParameterTypeRequiredDescription
dateNepaliDateYesTarget NepaliDate instance to compare against.

Return Value

  • Type: boolean
  • Returns true if year, month, and day are identical; otherwise returns false.

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.day

Two 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)); // true

Time 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)); // true

Advertisement

On this page