Skip to content

Documentation / jalali-js / diffDates

Function: diffDates() ​

diffDates(a, b, unit, system): number

Defined in: date-math.ts:85

The number of whole units between a and b, signed like compareDates(): positive when a is later, negative when a is earlier. Truncates toward zero: a unit counts only once it has fully passed, so 6 Mordad to 5 Shahrivar is 0 months and 6 Mordad to 6 Shahrivar is 1. Month and year steps use addMonths()/addYears(), clamping included, so diffDates(addMonths(d, n), d, 'month') is always n.

Parameters ​

a ​

CalendarDateFields

b ​

CalendarDateFields

unit ​

DiffUnit

system ​

CalendarSystem

Returns ​

number