0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 function obj = fromTimespanDef(obj, pli)
0018
0019 VERSION = '$Id: fromTimespanDef.m,v 1.2 2008/08/05 10:13:14 ingo Exp $';
0020
0021 ii = timespan.getInfo('timespan', 'From Timespan Definition');
0022
0023
0024 ii.setMversion([VERSION '-->' ii.mversion]);
0025
0026 t1 = pli.find('startT');
0027 if isempty(t1)
0028 t1 = pli.find('start');
0029 end
0030 t2 = pli.find('endT');
0031 if isempty(t2)
0032 t2 = pli.find('end');
0033 end
0034 tf = pli.find('timeformat');
0035 tz = pli.find('timezone');
0036
0037
0038 if ischar(t1) || isnumeric(t1)
0039 t1 = time(t1);
0040 elseif ~isa(t1, 'time')
0041 error('### The start time must be a string or a time-object. But it is from the class [%s]', class(t1));
0042 end
0043
0044 if ischar(t2) || isnumeric(t2)
0045 t2 = time(t2);
0046 elseif ~isa(t2, 'time')
0047 error('### The end time must be a string or a time-object. But it is from the class [%s]', class(t2));
0048 end
0049
0050 obj.startT = time(t1);
0051 obj.endT = time(t2);
0052
0053
0054 if isempty(tf)
0055 obj.setTimeformat(obj.startT.timeformat, 'internal');
0056 else
0057 obj.setTimeformat(tf, 'internal');
0058 end
0059 if isempty(tz)
0060 obj.setTimezone(obj.startT.timezone, 'internal');
0061 else
0062 obj.setTimezone(tz, 'internal');
0063 end
0064
0065
0066 obj = computeInterval(obj);
0067
0068
0069 obj.addHistory(ii, pli, [], obj.hist);
0070
0071 end