


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.2 2008/07/11 15:16:45 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.2 2008/07/11 15:16:45 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; 0051 0052 if length(time_str) ~=1 0053 0054 if length(pls) == 1 0055 time_str = {}; 0056 if nparams(pls) == 1 && isparam(pls, 'time_str') 0057 0058 %%% If the plist contains only one parameter with the key-word 'time_str' 0059 %%% then set 'time_str' to the value in the time object. 0060 time_str{1} = find(pls, 'time_str'); 0061 0062 else 0063 time_str{1} = pls; 0064 end 0065 elseif length(pls) > 1 0066 error('### To set the ''time_str'' please specify only one plist') 0067 else 0068 error('### Please specify [only one] value.') 0069 end 0070 end 0071 0072 %%% Set the time_str 0073 for ii = 1:numel(objs) 0074 %%% decide whether we modify the time-object, or create a new one. 0075 objs(ii) = copy(objs(ii), nargout); 0076 objs(ii) = compute_epoch_t(objs(ii), time_str{1}); 0077 end 0078 0079 %%% Prepare output 0080 varargout{1} = objs; 0081 0082 end 0083 0084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0085 % Local Functions % 0086 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0087 0088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0089 % 0090 % FUNCTION: compute_epoch_t 0091 % 0092 % DESCRIPTION: Compute the epoch time from a time-string. 0093 % 0094 % HISTORY: 07-07-2008 M Diepholz 0095 % Creation. 0096 % 0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0098 0099 function tt = compute_epoch_t(tt, time_str) 0100 [parse_java, parse_matlab] = time.parse_time_string(time_str); 0101 0102 tt.timeformat = parse_matlab; 0103 0104 t_format = java.text.SimpleDateFormat(parse_java); 0105 t_format.setTimeZone(tt.timezone); 0106 new_time = t_format.parse(time_str); 0107 0108 tt.utc_epoch_milli = new_time.getTime; 0109 end 0110 0111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0112 % 0113 % FUNCTION: getInfo 0114 % 0115 % DESCRIPTION: Get Info Object 0116 % 0117 % HISTORY: 11-07-07 M Hewitson 0118 % Creation. 0119 % 0120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0121 0122 function ii = getInfo(varargin) 0123 if nargin == 1 && strcmpi(varargin{1}, 'None') 0124 sets = {}; 0125 pl = []; 0126 else 0127 sets = {'Default'}; 0128 pl = getDefaultPlist; 0129 end 0130 % Build info object 0131 ii = minfo(mfilename, 'time', '', 'Internal', '$Id: setTime_str.m,v 1.2 2008/07/11 15:16:45 ingo Exp $', sets, pl); 0132 end 0133 0134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0135 % 0136 % FUNCTION: getDefaultPlist 0137 % 0138 % DESCRIPTION: Get Default Plist 0139 % 0140 % HISTORY: 11-07-07 M Hewitson 0141 % Creation. 0142 % 0143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0144 0145 function plo = getDefaultPlist() 0146 plo = plist('time_str', ''); 0147 end 0148