function [leapseconds] = calculateLeapseconds(pDate1, pDate2, pLeapsecondsMatrix)
%CALCULATELEAPSECIBDS Calculates the leapseconds between the two given dates based on the leapseconds matrix.
%
%   Parameters:
%       pDate1 (double)     The first date in rafos day, see
%                           artoa.convert.dmy2rd.
%       pDate2 (double)     The second date in rafos day.
%       pLeapsecondsMatrix  The matrix that 
%
%   Returns:
%       leapseconds (double) The calculated leapseconds


rd = artoa.convert.dmy2rd(pLeapsecondsMatrix(:, 1:3));
leap = pLeapsecondsMatrix(:, 4);

ax = find(rd <= pDate1);
bx = find(rd <= pDate2);

leapseconds = leap(max(ax)) - leap(max(bx));

