Mercurial > hg > ltpda
comparison m-toolbox/classes/@timespan/fromTimespanDef.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 % | |
3 % FUNCTION: fromTimespanDef | |
4 % | |
5 % DESCRIPTION: Construct an timespan from start and end time | |
6 % | |
7 % CALL: ts = fromTimespanDef(ts, t1, t2) | |
8 % | |
9 % INPUT: ts = timespan-object | |
10 % t1 = start time (char or time-object) | |
11 % t2 = end time (char or time-object) | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 function obj = fromTimespanDef(obj, pli) | |
15 | |
16 VERSION = '$Id: fromTimespanDef.m,v 1.17 2011/08/22 05:57:29 hewitson Exp $'; | |
17 | |
18 % get timespan info | |
19 ii = timespan.getInfo('timespan', 'From Timespan Definition'); | |
20 | |
21 % set the method version string in the minfo object | |
22 ii.setMversion([VERSION '-->' ii.mversion]); | |
23 | |
24 % apply default values | |
25 pl = applyDefaults(ii.plists, pli); | |
26 | |
27 % obtain parameters from plist | |
28 t1 = pl.find('startT'); | |
29 if isempty(t1) | |
30 t1 = pl.find('start'); | |
31 end | |
32 t2 = pl.find('endT'); | |
33 if isempty(t2) | |
34 t2 = pl.find('end'); | |
35 end | |
36 tf = find(pl, 'timeformat'); | |
37 tz = find(pl, 'timezone'); | |
38 | |
39 if isa(t1, 'time'); | |
40 % if parameter is a time object copy it | |
41 t1 = copy(t1, 1); | |
42 else | |
43 % otherwise costruct a time object from input parameters | |
44 t1 = time(plist('time', t1, 'timeformat', tf, 'timezone', tz)); | |
45 end | |
46 if isa(t2, 'time'); | |
47 % if parameter is a time object copy it | |
48 t2 = copy(t2, 1); | |
49 else | |
50 % otherwise costruct a time object from input parameters | |
51 t2 = time(plist('time', t2, 'timeformat', tf, 'timezone', tz)); | |
52 end | |
53 | |
54 % set start and end times | |
55 obj.startT = t1; | |
56 obj.endT = t2; | |
57 | |
58 % NOTE: in principle we should have been able to set the startT and endT | |
59 % in the plist and let setObjectProperties do the seeting, but since | |
60 % these properties have non-standard case, it's hard to dynamically | |
61 % construct the setter name. | |
62 | |
63 % add history | |
64 obj.addHistory(ii, pl, [], obj.hist); | |
65 | |
66 % set object properties from plist | |
67 obj.setObjectProperties(pl, {'startT', 'endT'}); | |
68 | |
69 end |