function sod = epoch_to_sod(time)
% sod = epoch_to_sod(time)
%
% Epoch (ANSI-C time, seconds since Jan 1, 1970) converted to seconds of
% day.
%
% time = vector of numeric time
%
% sod = vector of size equal to time filled with seconds of day for
%   each element in time
%
% Author: John Paden
%
% See also epoch_to_datenum.m, datenum_to_epoch.m, epoch_to_gps_sow.m,
%   epoch_to_sod.m, utc_leap_seconds.m

% Convert epoch to datenum (datenum is days since Jan 1, 1900)
time = epoch_to_datenum(time);
% Since time is in days, we just need to remove the decimal part
% to get the time at the beginning of the day for the first time
% sample.
ref_time = floor(time(1));
% Find the number of days relative to this reference time and then
% convert this to seconds of day
sod = 86400 * (time - ref_time);

return;
