Code covered by the BSD License  

Highlights from
mydate

mydate

by

 

16 Apr 2011 (Updated )

Augments MATLAB's date/time library for improved handling of epochs and formats commonly used in GPS

mydatestdi (epoch_std, year)
function epoch = mydatestdi (epoch_std, year)
%MYDATESTDI: Convert from standardized annual format (to epoch in internal format).
    [year_len, year_start] = mydatestd_aux(year);

    std_year_len = mydatestd_aux();

    epoch = epoch_std ./ std_year_len .* year_len + year_start;
    
    if any(epoch_std > 2.*std_year_len) ...
    || any(epoch_std <   -std_year_len)
        error('MATLAB:mydatestdi:outRange', ...
        'First argument is out of valid input range.');
    end

    year = repmat(year, length(epoch_std), 1);

    idx = (epoch_std > std_year_len);
    if any(idx)
        epoch(idx) = mydatestdi(epoch_std(idx)-std_year_len, year(idx)+1);
    end

    idx = (epoch_std < 0);
    if any(idx)
        epoch(idx) = mydatestdi(std_year_len-abs(epoch_std(idx)), year(idx)-1);
    end
end

%!test
%! % mydatestdi()
%! test('mydatestd_aux')

Contact us