Constructor examples of the TIMESPAN class


Construct empty TIMESPAN object
Construct a TIMESPAN object by loading the object from a file
Construct a TIMESPAN object with a start and end time
Construct a TIMESPAN object from a parameter list (PLIST) object

Construct empty TIMESPAN object

The following example creates an empty timespan object

ts = timespan()
---------- timespan 01 ----------

name      : None
start     : 2008-03-30 20:00:00.000
end       : 2008-03-30 20:00:00.000
timeformat: yyyy-mm-dd HH:MM:SS.FFF
interval  :
timezone  : UTC

created   : 2008-03-30 20:00:00.000
version   : $Id: timespan.m,v 1.23 2008/03/25 10:57:49 mauro Exp
plist     : plist class
---------------------------------

Construct a TIMESPAN object by loading the object from a file

The following example creates a new timespan object by loading the timespan object from disk.

t = timespan('timespan.mat')
t = timespan('timespan.xml')

Construct a TIMESPAN object with a start and end time

It is possible to specify the start-/end- time either with a time-object or with a time string.

t1_obj = time('14:00:00');
t2_obj = time('15:00:00');
t1_str = '14:00:00';
t2_str = '15:00:00';

ts1 = timespan(t1_obj, t2_obj)    % two time-objects
ts2 = timespan(t1_obj, t2_obj)    % two strings
ts3 = timespan(t1_str, t2_obj)    % combination of time-object and string
ts4 = timespan(t1_str, t2_str)    % combination of time-object and string

Construct a TIMESPAN object from a parameter list (PLIST) object

Construct an TIMESPAN by its properties definition

'start'

The starting time
[default: '1970-01-01 00:30:00.000']

'end'

The ending time
[default: '1980-01-01 12:00:00.010']

Additional parameters:

'timezone'

Timezone (string or java object) [default: 'UTC']

'timeformat'

Time format (string) [default: 'yyyy-mm-dd HH:MM:SS.FFF']

t1 = time('14:00:00');
t2 = time('15:00:00');

pl1 = plist('start', t1, ...
            'end',   t2);
pl2 = plist('start',       t1, ...
            'end',         t2, ...
            'timeformat', 'yyyy-mm-dd HH:MM:SS', ...
            'timezone',   'CET');

ts1 = timespan(pl1)
ts2 = timespan(pl2)



©LTP Team