Home > classes > @time > setEpochtime.m

setEpochtime

PURPOSE ^

SETEPOCHTIME Set the property 'utc_epoch_milli'.

SYNOPSIS ^

function varargout = setEpochtime(varargin)

DESCRIPTION ^

 SETEPOCHTIME Set the property 'utc_epoch_milli'.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: Set the property 'utc_epoch_milli'.

 CALL:        obj = obj.setEpochtime(123456);
              obj = obj.setEpochtime(plist('epochtime', 123456));
              obj = setEpochtime(obj, 123456);

 INPUTS:      obj - can be a vector, matrix, list, or a mix of them.
              pl  - to set the epochtime with a plist specify only one plist with
                    only one key-word 'epochtime'.

 M-FILE INFO: Get information about this methods by calling
              >> time.getInfo('setEpochtime')

              Get information about a specified set-plist by calling:
              >> time.getInfo('setEpochtime', 'set')

 VERSION:     $Id: setEpochtime.m,v 1.5 2008/09/04 15:29:31 ingo Exp $

 HISTORY:     27-05-2008 Diepholz
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % SETEPOCHTIME Set the property 'utc_epoch_milli'.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: Set the property 'utc_epoch_milli'.
0005 %
0006 % CALL:        obj = obj.setEpochtime(123456);
0007 %              obj = obj.setEpochtime(plist('epochtime', 123456));
0008 %              obj = setEpochtime(obj, 123456);
0009 %
0010 % INPUTS:      obj - can be a vector, matrix, list, or a mix of them.
0011 %              pl  - to set the epochtime with a plist specify only one plist with
0012 %                    only one key-word 'epochtime'.
0013 %
0014 % M-FILE INFO: Get information about this methods by calling
0015 %              >> time.getInfo('setEpochtime')
0016 %
0017 %              Get information about a specified set-plist by calling:
0018 %              >> time.getInfo('setEpochtime', 'set')
0019 %
0020 % VERSION:     $Id: setEpochtime.m,v 1.5 2008/09/04 15:29:31 ingo Exp $
0021 %
0022 % HISTORY:     27-05-2008 Diepholz
0023 %                 Creation
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 
0027 function varargout = setEpochtime(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}.utc_epoch_milli = 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   epochtime = rest;
0051 
0052   if length(epochtime) ~=1
0053 
0054     if length(pls) == 1
0055       epochtime = {};
0056       if nparams(pls) == 1 && isparam(pls, 'epochtime')
0057 
0058         %%% If the plist contains only one parameter with the key-word 'epochtime'
0059         %%% then set 'epochtime' to the value in the time object.
0060         epochtime{1} = find(pls, 'epochtime');
0061 
0062       else
0063         epochtime{1} = pls;
0064       end
0065     elseif length(pls) > 1
0066       error('### To set the ''epochtime'' please specify only one plist')
0067     else
0068       error('### Please specify [only one] value.')
0069     end
0070   end
0071 
0072   %%% Set the epochtime
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     if isnumeric(epochtime{1})
0077       objs(ii).utc_epoch_milli = epochtime{1};
0078     else
0079       error('### Epoch time must be numeric');
0080     end
0081   end
0082 
0083   %%% Prepare output
0084   varargout{1} = objs;
0085 
0086 end
0087 
0088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0089 %                               Local Functions                               %
0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0091 
0092 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0093 %
0094 % FUNCTION:    getInfo
0095 %
0096 % DESCRIPTION: Get Info Object
0097 %
0098 % HISTORY:     11-07-07 M Hewitson
0099 %                Creation.
0100 %
0101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0102 
0103 function ii = getInfo(varargin)
0104   if nargin == 1 && strcmpi(varargin{1}, 'None')
0105     sets = {};
0106     pl   = [];
0107   else
0108     sets = {'Default'};
0109     pl   = getDefaultPlist;
0110   end
0111   % Build info object
0112   ii = minfo(mfilename, 'time', '', utils.const.categories.internal, '$Id: setEpochtime.m,v 1.5 2008/09/04 15:29:31 ingo Exp $', sets, pl);
0113 end
0114 
0115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0116 %
0117 % FUNCTION:    getDefaultPlist
0118 %
0119 % DESCRIPTION: Get Default Plist
0120 %
0121 % HISTORY:     11-07-07 M Hewitson
0122 %                Creation.
0123 %
0124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0125 
0126 function plo = getDefaultPlist()
0127   plo = plist('utc_epoch_milli', '');
0128 end
0129

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003