Mercurial > hg > ltpda
comparison m-toolbox/classes/@time/plus.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 % PLUS Implements addition operator for time objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Implements addtion operator for time objects. Numeric and string | |
5 % operands are transparently handled converting them to time objects. Vector | |
6 % operands are handled accordingly to MATLAB conventions. | |
7 % | |
8 % VERSION: $Id: plus.m,v 1.20 2011/05/05 12:29:34 hewitson Exp $ | |
9 % | |
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | |
12 function t = plus(t1, t2) | |
13 | |
14 if isnumeric(t1) | |
15 d1 = t1*1000; | |
16 elseif ischar(t1) | |
17 d1 = time(t1).utc_epoch_milli; | |
18 elseif isa(t1, 'time') | |
19 d1 = t1.utc_epoch_milli; | |
20 else | |
21 error('LTPDA:TypeError', ... | |
22 '### unsupported operand classes for plus: ''%s'' and ''%s''', ... | |
23 class(t1), class(t2)); | |
24 end | |
25 | |
26 if isnumeric(t2) | |
27 d2 = t2*1000; | |
28 elseif ischar(t2) | |
29 d2 = time(t2).utc_epoch_milli; | |
30 elseif isa(t2, 'time') | |
31 d2 = t2.utc_epoch_milli; | |
32 else | |
33 error('LTPDA:TypeError', ... | |
34 '### unsupported operand classes for plus: ''%s'' and ''%s''', ... | |
35 class(t1), class(t2)); | |
36 end | |
37 | |
38 t = time((d1 + d2)/1000); | |
39 end |