Home > matutils > dateconv > mjd2string.m

mjd2string

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function times = mjd2string(times)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  function times = mjd2str(times)

  converst mjd to strings that can be read into read_arc

  sjcm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function times = mjd2string(times)
0002 
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %  function times = mjd2str(times)
0005 %
0006 %  converst mjd to strings that can be read into read_arc
0007 %
0008 %  sjcm
0009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0010 
0011 s = size(times,1);
0012 times = mjd2date_v2(times);
0013 
0014 months = ['JAN'; 'FEB'; 'MAR'; 'APR'; 'MAY'; 'JUN'; 'JUL'; 'AUG'; ...
0015       'SEP'; 'OCT'; 'NOV'; 'DEC'];
0016 times.month = months(times.month,:);
0017 dash = repmat(['-'], size(times.day));
0018 colon = repmat([':'], size(times.day));
0019 if(s==1)
0020     times.second(1) = floor(times.second(1));
0021 else
0022     times.second(1:s/2) = floor(times.second(1:s/2));
0023     times.second(s/2+1:s) = ceil(times.second(s/2+1:s));
0024 end
0025 
0026 f = find(times.second ==60) ;
0027 if(~isempty(f))
0028   times.second(f) = 0;
0029   times.minute(f) = times.minute(f)+1;
0030 end
0031 f = find(times.minute  == 60);
0032 if(~isempty(f))
0033   times.minute(f) = 0;
0034   times.hour(f) = times.hour(f) + 1;
0035 end
0036 f = find(times.hour == 24);
0037 if(~isempty(f))
0038   times.hour(f) = 0;
0039   times.day(f) = times.day(f) + 1;
0040 end
0041 % yes...i know it will have a problem with months...but it shouldn't since we are just doing the arrayHealht on a given day.
0042 
0043 times.hourString = num2str(times.hour);
0044 f = find(times.hour<10);
0045 if(~isempty(f))
0046   for m=1:length(f)
0047      times.hourString(f(m),1:2) = sprintf('0%d', times.hour(f(m),:));
0048   end
0049 end
0050 
0051 times.minuteString = num2str(times.minute);
0052 f = find(times.minute<10);
0053 if(~isempty(f))
0054   for m=1:length(f)
0055      times.minuteString(f(m),1:2) = sprintf('0%d', times.minute(f(m),:));
0056   end
0057 end
0058 
0059 times.secondString = num2str(times.second);
0060 f = find(times.second<10);
0061 if(~isempty(f))
0062   for m=1:length(f)
0063      times.secondString(f(m),1:2) = sprintf('0%d', times.second(f(m),:));
0064   end
0065 end
0066 
0067 str = cat(2, num2str(times.day), dash, times.month, dash, num2str(times.year), colon, times.hourString, colon, times.minuteString, colon, times.secondString);
0068 
0069 times = str;
0070 
0071 return

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005