% ----------------- % Copyright © 2022 ACK Cyfronet AGH, Poland. % ----------------- % % Get string format for the time values provided in timeVector. Format is based % on numeric 'FieldType' (GDF) or 'type' (catalog) field % see https://docs.cyfronet.pl/display/ISEPOS/GDF+v2.2+-+description function timeStrVector = formatTime(timeVector, fieldType) % if we have '5a' and '5b', the date value is a string instead of a number) if (ischar(fieldType) && (strcmp(fieldType, '5a') || strcmp(fieldType, '5b'))) timeStrVector = timeVector; return; end if iscell(timeVector) timeVector = cell2mat(timeVector); end emptyIndexes = isnan(timeVector); timeFormat = getTimeFormat(fieldType); timeStrVector(~emptyIndexes, 1) = cellstr(datestr(timeVector(~emptyIndexes), timeFormat)); timeStrVector(emptyIndexes, 1) = { 'NaN' }; end function timeFormat = getTimeFormat(fieldType) if (fieldType == 5) timeFormat = 'yyyy mmm dd HH:MM:SS.FFF'; else timeFormat = arrayfun(@changeToMatlabFormat, fieldType(2:end)); end end % Matlab uses different specification of the format than the one used in GDF files (based on Java format) - e.g., 'M' is % used in GDF for month, while in Matlab it is used for minutes function correctedFormatId = changeToMatlabFormat(javaTimeFormatId) switch javaTimeFormatId case 'M' correctedFormatId = 'm'; case 'm' correctedFormatId = 'M'; case 's' correctedFormatId = 'S'; case 'S' correctedFormatId = 'F'; otherwise correctedFormatId = javaTimeFormatId; end end