Home > classes > @timeformat > set.m

set

PURPOSE ^

SET set timeformat properties.

SYNOPSIS ^

function tf = set(tf, varargin)

DESCRIPTION ^

 SET set timeformat properties.

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

 DESCRIPTION: SET set timeformat properties.

 CALL:        tf = set(tf, 'property', 'value');
              tf = set(tf, 'property', 'value', 'direct');

 EXAMPLES:    tt = set(tt, 'format_str',         'yyyy.dd.mm HH:MM:SS AM');
              tt = set(tt, 'format_nr',           0);
              tt = set(tt, 'default_matlab_str', 'yyyy-mm-dd HH:MM:SS');
              tt = set(tt, 'default_matlab_nr',   31);
              tt = set(tt, 'default_java_str',   'yyyy-MM-dd HH:mm:ss');

 VERSION:     $Id: set.m,v 1.2 2007/08/20 16:04:58 ingo Exp $

 HISTORY:     23-07-2007 Diepholz
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function tf = set(tf, varargin)
0002 % SET set timeformat properties.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: SET set timeformat properties.
0007 %
0008 % CALL:        tf = set(tf, 'property', 'value');
0009 %              tf = set(tf, 'property', 'value', 'direct');
0010 %
0011 % EXAMPLES:    tt = set(tt, 'format_str',         'yyyy.dd.mm HH:MM:SS AM');
0012 %              tt = set(tt, 'format_nr',           0);
0013 %              tt = set(tt, 'default_matlab_str', 'yyyy-mm-dd HH:MM:SS');
0014 %              tt = set(tt, 'default_matlab_nr',   31);
0015 %              tt = set(tt, 'default_java_str',   'yyyy-MM-dd HH:mm:ss');
0016 %
0017 % VERSION:     $Id: set.m,v 1.2 2007/08/20 16:04:58 ingo Exp $
0018 %
0019 % HISTORY:     23-07-2007 Diepholz
0020 %                 Creation
0021 %
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 
0024 if (nargout ~= 0)
0025 
0026   compute = true;
0027   if nargin == 4 && strcmp(varargin{3}, 'direct')
0028     compute = false;
0029   end
0030 
0031   property_argin = varargin;
0032 
0033   fields = fieldnames(tf);
0034 
0035   while length(property_argin) >= 2
0036     prop = property_argin{1};
0037     val  = property_argin{2};
0038     property_argin = property_argin(3:end);
0039 
0040     if ~ismember(prop, fields)
0041       error(['### ', prop, ' is not a valid time property.']);
0042     else
0043 
0044       % Set the format string
0045       if (strcmp(prop, 'format_str')) && (compute)
0046         if ischar(val)
0047           tf.format_str = val;
0048           if strcmp(tf.format_str, tf.default_matlab_str)
0049             tf.format_nr = tf.default_matlab_nr;
0050           else
0051             tf.format_nr = -1;
0052           end
0053         else
0054           error('### Please use for %s a format-string', tf.(field));
0055         end
0056 
0057       % Set the format number
0058       elseif (strcmp (prop, 'format_nr')) && (compute)
0059         if isnumeric(val)
0060           tf.format_nr = val;
0061           if (tf.format_nr == tf.default_matlab_nr)
0062             tf.format_str = tf.default_matlab_str;
0063           else
0064             tf.format_str = '';
0065           end
0066         else
0067           error('### Please use for %s a matlab format-number', tf.(field));
0068         end
0069       else
0070         tf.(prop) = val;
0071       end
0072 
0073     end
0074 
0075 
0076   end
0077 
0078 else
0079   if ischar(varargin{2})
0080     error('### please use: %s = set(%s, ''%s'', ''%s'');', ...
0081                         inputname(1), ...
0082                         inputname(1), ...
0083                         varargin{1},  ...
0084                         varargin{2});
0085   elseif isnumeric(varargin{2})
0086     error('### please use: %s = set(%s, ''%s'', %d);', ...
0087                         inputname(1), ...
0088                         inputname(1), ...
0089                         varargin{1},  ...
0090                         varargin{2});
0091   else
0092     error('### please use: %s = set(%s, ''key'', ''value'');', ...
0093                         inputname(1), ...
0094                         inputname(1));
0095   end
0096 end

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003