function UTC = astHelperLongitudeHour(obs)
% ASTHELPERLONGITUDEHOUR This helper function adjusts the UTC time for the
% observation structure based on the vessel's longitude. This function
% makes updates to hours and days are made to make sure they do not go
% beyond their bounds. The Celestial Navigation Example uses this function.
% Do not call this function independently.

% Copyright 2012-2013 The MathWorks, Inc.

% Assign year.
UTC(1) = obs.year;

% Assign month.
UTC(2) = obs.month;

% Assign day.
UTC(3) = obs.day;

% Assign hour.
hourLongitude = obs.longitude/15;
UTC(4) = obs.hour - fix(hourLongitude);

% Assign minutes.
UTC(5) = floor(mod(-hourLongitude,1)*60);

% Assign seconds.
UTC(6) = mod(mod(-hourLongitude,1)*60,1)*60;

% Adjustments might be required if the minutes exceed 60, the hours exceed
% 24 or the days exceed 31. 

% Minute adjustment.
if UTC(5)>59
    UTC(4) = UTC(4)+floor(UTC(5)/60);
    UTC(5) = rem(UTC(5),60);
end

% Hour adjustment.
if UTC(4)>23
    UTC(3) = UTC(3) + floor(UTC(4)/24);
    UTC(4) = rem(UTC(4),24);
end

% Day adjustment.
[UTC(2),UTC(3)] = astHelperDayCheck(UTC(1),UTC(2),UTC(3));

%[EOF]