Home > classes > @timespan > fromTimespanDef.m

fromTimespanDef

PURPOSE ^

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

SYNOPSIS ^

function obj = fromTimespanDef(obj, pli)

DESCRIPTION ^

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

 FUNCTION:    fromTimespanDef

 DESCRIPTION: Construct an timespan from start and end time

 CALL:        ts = fromTimespanDef(ts, t1, t2)

 INPUT:       ts = timespan-object
              t1 = start time (char or time-object)
              t2 = end   time (char or time-object)

 HISTORY:     23-07-2008 Diepholz
              Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %
0003 % FUNCTION:    fromTimespanDef
0004 %
0005 % DESCRIPTION: Construct an timespan from start and end time
0006 %
0007 % CALL:        ts = fromTimespanDef(ts, t1, t2)
0008 %
0009 % INPUT:       ts = timespan-object
0010 %              t1 = start time (char or time-object)
0011 %              t2 = end   time (char or time-object)
0012 %
0013 % HISTORY:     23-07-2008 Diepholz
0014 %              Creation
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   % get timespan info
0021   ii = timespan.getInfo('timespan', 'From Timespan Definition');
0022 
0023   % Set the method version string in the minfo object
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   % Adjust the 'timeformat' AND the 'timezone' of the end time to the start time.
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   % Compute the interval
0066   obj = computeInterval(obj);
0067   
0068   % Add history
0069   obj.addHistory(ii, pli, [], obj.hist);
0070 
0071 end

Generated on Mon 25-Aug-2008 22:39:29 by m2html © 2003