Mercurial > hg > ltpda
comparison m-toolbox/classes/@time/format.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 % FORMAT Formats a time object into a string | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: FORMAT(TIME, FRMT, TIMEZONE) Formats the time object TIME into a | |
5 % string, accordingly to the format descrption FRMT and the timezone TIMEZONE. | |
6 % | |
7 % The FRMT format description can be a format number or a free form date format | |
8 % string, as accepted by the datestr() MATLAB function. The FRMT and TIMEZONE | |
9 % arguments are optional, if they are not specified or empty, the ones stored in | |
10 % the toolbox user preferences are used. | |
11 % | |
12 % EXAMPLES: | |
13 % | |
14 % >> t = time(); | |
15 % >> t.format(); | |
16 % >> t.format('yyyy-mm-dd HH:MM:SS.FFF z'); | |
17 % >> t.format('yyyy-mm-dd HH:MM:SS.FFF z', 'UTC'); | |
18 % | |
19 % SEE ALSO: datestr time/strftime | |
20 % | |
21 % VERSION: $Id: format.m,v 1.19 2010/07/29 18:07:55 nicolodi Exp $ | |
22 % | |
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
24 | |
25 function str = format(tt, frmt, timezone) | |
26 | |
27 % check input arguments | |
28 error(nargchk(1, 3, nargin, 'struct')); | |
29 | |
30 % second and third arguments are optional | |
31 if nargin < 3 | |
32 timezone = ''; | |
33 end | |
34 if nargin < 2 | |
35 frmt = ''; | |
36 end | |
37 | |
38 % format all input time objects | |
39 str = time.strftime(tt(1).utc_epoch_milli, frmt, timezone); | |
40 for k = 2:numel(tt) | |
41 str = [ str ', ' time.strftime(tt(1).utc_epoch_milli, frmt, timezone)]; | |
42 end | |
43 | |
44 end | |
45 |