SETTIME_STR Set the property 'time_str'. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Set the property 'time_str'. CALL: obj = obj.setTime_str('new time_str'); obj = obj.setTime_str(plist('time_str', 'new time_str')); obj = setTime_str(obj, 'new time_str'); INPUTS: obj - can be a vector, matrix, list, or a mix of them. pl - to set the time_str with a plist specify only one plist with only one key-word 'time_str'. M-FILE INFO: Get information about this methods by calling >> time.getInfo('setTime_str') Get information about a specified set-plist by calling: >> time.getInfo('setTime_str', 'set') VERSION: $Id: setTime_str.m,v 1.4 2008/09/04 15:29:31 ingo Exp $ HISTORY: 27-05-2008 Diepholz Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % SETTIME_STR Set the property 'time_str'. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: Set the property 'time_str'. 0005 % 0006 % CALL: obj = obj.setTime_str('new time_str'); 0007 % obj = obj.setTime_str(plist('time_str', 'new time_str')); 0008 % obj = setTime_str(obj, 'new time_str'); 0009 % 0010 % INPUTS: obj - can be a vector, matrix, list, or a mix of them. 0011 % pl - to set the time_str with a plist specify only one plist with 0012 % only one key-word 'time_str'. 0013 % 0014 % M-FILE INFO: Get information about this methods by calling 0015 % >> time.getInfo('setTime_str') 0016 % 0017 % Get information about a specified set-plist by calling: 0018 % >> time.getInfo('setTime_str', 'set') 0019 % 0020 % VERSION: $Id: setTime_str.m,v 1.4 2008/09/04 15:29:31 ingo Exp $ 0021 % 0022 % HISTORY: 27-05-2008 Diepholz 0023 % Creation 0024 % 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 0027 function varargout = setTime_str(varargin) 0028 0029 %%% Check if this is a call for parameters 0030 if utils.helper.isinfocall(varargin{:}) 0031 varargout{1} = getInfo(varargin{3}); 0032 return 0033 end 0034 0035 %%% Internal call: Only one object + don't look for a plist 0036 if strcmp(varargin{end}, 'internal') 0037 0038 %%% decide whether we modify the time-object, or create a new one. 0039 varargin{1} = copy(varargin{1}, nargout); 0040 0041 varargin{1} = compute_epoch_t(varargin{1}, varargin{2}); 0042 varargout{1} = varargin{1}; 0043 return 0044 end 0045 0046 %%% Normal call: 0047 [objs, invars, rest] = utils.helper.collect_objects(varargin(:), 'time'); 0048 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); 0049 0050 time_str = rest{1}; 0051 if ~ischar(time_str) 0052 error('### Time string must be a string'); 0053 end 0054 0055 if length(time_str) ~=1 0056 0057 if length(pls) == 1 0058 time_str = {}; 0059 if nparams(pls) == 1 && isparam(pls, 'time_str') 0060 0061 %%% If the plist contains only one parameter with the key-word 'time_str' 0062 %%% then set 'time_str' to the value in the time object. 0063 time_str = find(pls, 'time_str'); 0064 0065 else 0066 time_str = pls; 0067 end 0068 elseif length(pls) > 1 0069 error('### To set the ''time_str'' please specify only one plist') 0070 else 0071 error('### Please specify [only one] value.') 0072 end 0073 end 0074 0075 %%% Set the time_str 0076 for ii = 1:numel(objs) 0077 %%% decide whether we modify the time-object, or create a new one. 0078 objs(ii) = copy(objs(ii), nargout); 0079 objs(ii) = compute_epoch_t(objs(ii), time_str); 0080 end 0081 0082 %%% Prepare output 0083 varargout{1} = objs; 0084 0085 end 0086 0087 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0088 % Local Functions % 0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0090 0091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0092 % 0093 % FUNCTION: compute_epoch_t 0094 % 0095 % DESCRIPTION: Compute the epoch time from a time-string. 0096 % 0097 % HISTORY: 07-07-2008 M Diepholz 0098 % Creation. 0099 % 0100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0101 0102 function tt = compute_epoch_t(tt, time_str) 0103 [parse_java, parse_matlab] = time.parse_time_string(time_str); 0104 0105 tt.timeformat = parse_matlab; 0106 0107 t_format = java.text.SimpleDateFormat(parse_java); 0108 t_format.setTimeZone(tt.timezone); 0109 new_time = t_format.parse(time_str); 0110 0111 tt.utc_epoch_milli = new_time.getTime; 0112 end 0113 0114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0115 % 0116 % FUNCTION: getInfo 0117 % 0118 % DESCRIPTION: Get Info Object 0119 % 0120 % HISTORY: 11-07-07 M Hewitson 0121 % Creation. 0122 % 0123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0124 0125 function ii = getInfo(varargin) 0126 if nargin == 1 && strcmpi(varargin{1}, 'None') 0127 sets = {}; 0128 pl = []; 0129 else 0130 sets = {'Default'}; 0131 pl = getDefaultPlist; 0132 end 0133 % Build info object 0134 ii = minfo(mfilename, 'time', '', utils.const.categories.internal, '$Id: setTime_str.m,v 1.4 2008/09/04 15:29:31 ingo Exp $', sets, pl); 0135 end 0136 0137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0138 % 0139 % FUNCTION: getDefaultPlist 0140 % 0141 % DESCRIPTION: Get Default Plist 0142 % 0143 % HISTORY: 11-07-07 M Hewitson 0144 % Creation. 0145 % 0146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0147 0148 function plo = getDefaultPlist() 0149 plo = plist('time_str', ''); 0150 end 0151