Home > matutils > dateconv > tstr2date.m

tstr2date

PURPOSE ^

function t=tstr2date(time)

SYNOPSIS ^

function t=tstr2date(time)

DESCRIPTION ^

 function t=tstr2date(time)
 
 input time in sza string format, ie 12-JUN-05:12:12:12
 and returns struct t:

 t.day=12;
 t.month='JUN';
 t.year=5;
 t.hour=12;
 t.min=12;
 t.sec=12;

 Michael Loh

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t=tstr2date(time)
0002 
0003 % function t=tstr2date(time)
0004 %
0005 % input time in sza string format, ie 12-JUN-05:12:12:12
0006 % and returns struct t:
0007 %
0008 % t.day=12;
0009 % t.month='JUN';
0010 % t.year=5;
0011 % t.hour=12;
0012 % t.min=12;
0013 % t.sec=12;
0014 %
0015 % Michael Loh
0016 
0017 % find all "-' and replace with ':'
0018 f=find(time=='-');
0019 time(f)=':';
0020 
0021 f=find(time==':');
0022 
0023 if (length(f)<4)
0024   error('Invalid time')
0025 end
0026 
0027 f=[0 f length(time)+1];
0028 for i=2:length(f)
0029   if (i==3)
0030     c{i-1}=time(f(2)+1:f(3)-1);
0031     c{i-1}=upper(c{i-1});
0032   else
0033     c{i-1}=str2num(time(f(i-1)+1:f(i)-1));
0034   end
0035 end
0036 
0037 cnt=length(c);
0038 dif=6-cnt;
0039 if (dif)
0040   for i=1:dif
0041     c{cnt+i}=0;
0042   end
0043 end
0044 
0045 t.day=c{1};
0046 t.month=c{2};
0047 t.year=c{3};
0048 t.hour=c{4};
0049 t.min=c{5};
0050 t.sec=c{6};

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