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.3 2008/07/23 17:31:56 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.3 2008/07/23 17:31:56 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     objs(ii).utc_epoch_milli = epochtime{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:    getInfo
0091 %
0092 % DESCRIPTION: Get Info Object
0093 %
0094 % HISTORY:     11-07-07 M Hewitson
0095 %                Creation.
0096 %
0097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0098 
0099 function ii = getInfo(varargin)
0100   if nargin == 1 && strcmpi(varargin{1}, 'None')
0101     sets = {};
0102     pl   = [];
0103   else
0104     sets = {'Default'};
0105     pl   = getDefaultPlist;
0106   end
0107   % Build info object
0108   ii = minfo(mfilename, 'time', '', 'Internal', '$Id: setEpochtime.m,v 1.3 2008/07/23 17:31:56 ingo Exp $', sets, pl);
0109 end
0110 
0111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0112 %
0113 % FUNCTION:    getDefaultPlist
0114 %
0115 % DESCRIPTION: Get Default Plist
0116 %
0117 % HISTORY:     11-07-07 M Hewitson
0118 %                Creation.
0119 %
0120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0121 
0122 function plo = getDefaultPlist()
0123   plo = plist('utc_epoch_milli', '');
0124 end
0125

Generated on Mon 25-Aug-2008 22:39:29 by m2html © 2003