function [leapSeconds] = getLeapSecondsUTC(Tutc)
% getLeapSecondsUTC : Returns the number of seconds by which GPS lead UTC at
%                     the specified input UTC epochs.
%
%
% INPUTS
%
% Tutc ----------- N-by-1 vector of UTC times expressed as datetimes.
%
%
% OUTPUTS
% 
% leapSeconds----- N-by-1 vector of seconds by which GPS time leads UTC at the
%                  corresponding epochs.
%                      
%+------------------------------------------------------------------------------+
% References:
%
%
% Author:  Todd Humphreys
%+==============================================================================+
  
N = length(Tutc);
if(sum(isdatetime(Tutc)) ~= N)
  error('Input must be a datetime object');
end
  
% Notes: These are the leap seconds that came into effect after midnight
% UTC on the indicated days.
%
% June     30, 1997     	12 seconds
% December 31, 1998		13 seconds
% December 31, 2005		14 seconds
% December 31, 2008		15 seconds
% June     30, 2012     	16 seconds
% June     30, 2015             17 seconds
% December 31, 2016             18 seconds
  
% UTC times corresponding to the transition instants 
T12 = datetime(1997, 6,30,0,0,0) + 1;
T13 = datetime(1998,12,31,0,0,0) + 1;
T14 = datetime(2005,12,31,0,0,0) + 1;
T15 = datetime(2008,12,31,0,0,0) + 1;
T16 = datetime(2012, 6,30,0,0,0) + 1;
T17 = datetime(2015, 6,30,0,0,0) + 1;
T18 = datetime(2016,12,31,0,0,0) + 1;

leapSeconds = zeros(length(Tutc), 1);
leapSeconds(Tutc <  T12) = 11;
leapSeconds(Tutc >= T12 & Tutc < T13) = 12;
leapSeconds(Tutc >= T13 & Tutc < T14) = 13;
leapSeconds(Tutc >= T14 & Tutc < T15) = 14;
leapSeconds(Tutc >= T15 & Tutc < T16) = 15;
leapSeconds(Tutc >= T16 & Tutc < T17) = 16;
leapSeconds(Tutc >= T17 & Tutc < T18) = 17;
leapSeconds(Tutc >= T18) = 18;


  

