This is a static copy of a profile report

Home

datestr (6 calls, 0.050 sec)
Generated 14-Nov-2016 07:47:22 using cpu time.
function in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/timefun/datestr.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
graphics/private/imwriteArgsForPrintfunction3
imagesci/private/writepngfunction3
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
194
S = dateformverify(dtnumber, d...
60.050 s100.0%
184
if (last < 1) || (isnumeric...
60 s0%
183
dtnumber = dtnumber(:);
60 s0%
175
end
30 s0%
174
dtnumber = D;
30 s0%
All other lines  0 s0%
Totals  0.050 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
timefun/private/dateformverifyfunction60.050 s100.0%
datenumfunction30 s0%
datestr>getdateformsubfunction60 s0%
Self time (built-ins, overhead, etc.)  0 s0%
Totals  0.050 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function194
Non-code lines (comments, blank lines)137
Code lines (lines that can run)57
Code lines that did run24
Code lines that did not run33
Coverage (did run/can run)42.11 %
Function listing
time 
calls 
 line
   1 
function S = datestr(D,varargin)
   2 
%DATESTR String representation of date.
   3 
%   S = DATESTR(V) converts one or more date vectors V to date strings S.
   4 
%   Input V must be an M-by-6 matrix containing M full (six-element) date
   5 
%   vectors. Each element of V must be a positive double-precision number.
   6 
%   DATESTR returns a column vector of M date strings, where M is the total
   7 
%   number of date vectors in V. 
   8 
%
   9 
%   S = DATESTR(N) converts one or more serial date numbers N to date
  10 
%   strings S. Input argument N can be a scalar, vector, or
  11 
%   multidimensional array of positive double-precision numbers. DATESTR
  12 
%   returns a column vector of M date strings, where M is the total number
  13 
%   of date numbers in N. 
  14 
%
  15 
%   S = DATESTR(D, F) converts one or more date vectors, serial date
  16 
%   numbers, or date strings D into the same number of date strings S.
  17 
%   Input argument F is a format number or string that determines the
  18 
%   format of the date string output. Valid values for F are given in Table
  19 
%   1, below. Input F may also contain a free-form date format string
  20 
%   consisting of format tokens as shown in Table 2, below. 
  21 
%
  22 
%   Date strings with 2-character years are interpreted to be within the
  23 
%   100 years centered around the current year. 
  24 
%
  25 
%   S = DATESTR(S1, F, P) converts date string S1 to date string S,
  26 
%   applying format F to the output string, and using pivot year P as the
  27 
%   starting year of the 100-year range in which a two-character year
  28 
%   resides. The default pivot year is the current year minus 50 years.
  29 
%   F = -1 uses the default format.
  30 
%
  31 
%	S = DATESTR(...,'local') returns the string in a localized format. The
  32 
%	default (which can be called with 'en_US') is US English. This argument 
  33 
%	must come last in the argument sequence.
  34 
%
  35 
%	Note:  The vectorized calling syntax can offer significant performance
  36 
%	improvement for large arrays.
  37 
%
  38 
%	Table 1: Standard MATLAB Date format definitions
  39 
%
  40 
%   Number           String                   Example
  41 
%   ===========================================================================
  42 
%      0             'dd-mmm-yyyy HH:MM:SS'   01-Mar-2000 15:45:17 
  43 
%      1             'dd-mmm-yyyy'            01-Mar-2000  
  44 
%      2             'mm/dd/yy'               03/01/00     
  45 
%      3             'mmm'                    Mar          
  46 
%      4             'm'                      M            
  47 
%      5             'mm'                     03            
  48 
%      6             'mm/dd'                  03/01        
  49 
%      7             'dd'                     01            
  50 
%      8             'ddd'                    Wed          
  51 
%      9             'd'                      W            
  52 
%     10             'yyyy'                   2000         
  53 
%     11             'yy'                     00           
  54 
%     12             'mmmyy'                  Mar00        
  55 
%     13             'HH:MM:SS'               15:45:17     
  56 
%     14             'HH:MM:SS PM'             3:45:17 PM  
  57 
%     15             'HH:MM'                  15:45        
  58 
%     16             'HH:MM PM'                3:45 PM     
  59 
%     17             'QQ-YY'                  Q1-96        
  60 
%     18             'QQ'                     Q1           
  61 
%     19             'dd/mm'                  01/03        
  62 
%     20             'dd/mm/yy'               01/03/00     
  63 
%     21             'mmm.dd,yyyy HH:MM:SS'   Mar.01,2000 15:45:17 
  64 
%     22             'mmm.dd,yyyy'            Mar.01,2000  
  65 
%     23             'mm/dd/yyyy'             03/01/2000 
  66 
%     24             'dd/mm/yyyy'             01/03/2000 
  67 
%     25             'yy/mm/dd'               00/03/01 
  68 
%     26             'yyyy/mm/dd'             2000/03/01 
  69 
%     27             'QQ-YYYY'                Q1-1996        
  70 
%     28             'mmmyyyy'                Mar2000        
  71 
%     29 (ISO 8601)  'yyyy-mm-dd'             2000-03-01
  72 
%     30 (ISO 8601)  'yyyymmddTHHMMSS'        20000301T154517 
  73 
%     31             'yyyy-mm-dd HH:MM:SS'    2000-03-01 15:45:17 
  74 
%
  75 
%   Table 2: Date format symbolic identifiers (Examples are in US English)
  76 
%   
  77 
%   Symbol  Interpretation of format symbol
  78 
%   ===========================================================================
  79 
%   yyyy    full year, e.g. 1990, 2000, 2002
  80 
%   yy      partial year, e.g. 90, 00, 02
  81 
%   mmmm    full name of the month, according to the calendar locale, e.g.
  82 
%           "March", "April". 
  83 
%   mmm     first three letters of the month, according to the calendar 
  84 
%           locale, e.g. "Mar", "Apr". 
  85 
%   mm      numeric month of year, padded with leading zeros, e.g. ../03/..
  86 
%           or ../12/.. 
  87 
%   m       capitalized first letter of the month, according to the
  88 
%           calendar locale; for backwards compatibility. 
  89 
%   dddd    full name of the weekday, according to the calendar locale, e.g.
  90 
%           "Monday", "Tuesday". 
  91 
%   ddd     first three letters of the weekday, according to the calendar
  92 
%           locale, e.g. "Mon", "Tue". 
  93 
%   dd      numeric day of the month, padded with leading zeros, e.g. 
  94 
%           05/../.. or 20/../.. 
  95 
%   d       capitalized first letter of the weekday; for backwards 
  96 
%           compatibility
  97 
%   HH      hour of the day, according to the time format. In case the time
  98 
%           format AM | PM is set, HH does not pad with leading zeros. In 
  99 
%           case AM | PM is not set, display the hour of the day, padded 
 100 
%           with leading zeros. e.g 10:20 PM, which is equivalent to 22:20; 
 101 
%           9:00 AM, which is equivalent to 09:00.
 102 
%   MM      minutes of the hour, padded with leading zeros, e.g. 10:15, 
 103 
%           10:05, 10:05 AM.
 104 
%   SS      second of the minute, padded with leading zeros, e.g. 10:15:30,
 105 
%           10:05:30, 10:05:30 AM. 
 106 
%   FFF     milliseconds field, padded with leading zeros, e.g.
 107 
%           10:15:30.015.
 108 
%   PM      insert AM or PM in date string
 109 
%
 110 
%   Examples:
 111 
%	DATESTR(now) returns '24-Jan-2003 11:58:15' for that particular date,
 112 
%	on an US English locale DATESTR(now,2) returns 01/24/03, the same as
 113 
%	for DATESTR(now,'mm/dd/yy') DATESTR(now,'dd.mm.yyyy') returns
 114 
%	24.01.2003 To convert a non-standard date form into a standard MATLAB
 115 
%	dateform, first convert the non-standard date form to a date number,
 116 
%	using DATENUM, for example, 
 117 
%	DATESTR(DATENUM('24.01.2003','dd.mm.yyyy'),2) returns 01/24/03.
 118 
%
 119 
%	See also DATE, DATENUM, DATEVEC, DATETICK.
 120 

 121 
%	Copyright 1984-2012 The MathWorks, Inc.
 122 

 123 
%==============================================================================
 124 
% handle input arguments
      6 
 125 
narginchk(1,4); 
      6 
 126 
last = nargin - 1; 
      6 
 127 
islocal = 0; 
      6 
 128 
if last > 0 && ischar(varargin{end}) 
 129 
    if strcmpi(varargin{end}, 'local')
 130 
        islocal = 1;
 131 
        last = last - 1;
 132 
    elseif strcmpi(varargin{end},'en_us')
 133 
        islocal = 0;
 134 
        last = last - 1;
 135 
    end
 136 
end
 137 

      6 
 138 
if last > 2 
 139 
    % Force narginchk to error
 140 
    narginchk(1,2);
      6 
 141 
elseif last >= 1 
      6 
 142 
    dateform = varargin{1}; 
      6 
 143 
    if last == 2 
 144 
        pivotyear = varargin{2};
 145 
    end
      6 
 146 
end 
 147 

      6 
 148 
isdatestr = ~isnumeric(D); 
      6 
 149 
if last > 0 
      6 
 150 
    if ~ischar(dateform); 
 151 
        % lookup date form string on index
      6 
 152 
        dateformstr = getdateform(dateform); 
 153 
    else
 154 
        dateformstr = dateform;
 155 
    end
 156 
else
 157 
    dateformstr = '';
 158 
end
 159 

      6 
 160 
if last == 2 && ischar(pivotyear) 
 161 
    error(message('MATLAB:datestr:InputClass'));
 162 
end
 163 

 164 
% Convert strings and clock vectors to date numbers.
      6 
 165 
try 
      6 
 166 
    if isdatestr || (size(D,2)==6 && all(all(D(:,1:5)==fix(D(:,1:5)))) &&... 
 167 
        all(abs(sum(D,2)-2000)<500)) 
      3 
 168 
        if last <= 1 || ~isdatestr  %not a datestring or no pivot year. 
      3 
 169 
            dtnumber = datenum(D); 
 170 
        else %datestring and pivot year were passed in.
 171 
            dtnumber = datenum(D,pivotyear);
 172 
        end
      3 
 173 
    else %datenum was passed in 
      3 
 174 
        dtnumber = D; 
      3 
 175 
    end 
 176 
catch exception 
 177 
    error(message('MATLAB:datestr:ConvertToDateNumber', exception.message));
 178 
end
 179 

 180 
% Determine format if none specified.  If all the times are zero,
 181 
% display using date only.  If all dates are all zero display time only.
 182 
% Otherwise display both time and date.
      6 
 183 
dtnumber = dtnumber(:); 
      6 
 184 
if (last < 1) || (isnumeric(dateform) && (dateform == -1)) 
 185 
   if all(floor(dtnumber)==dtnumber)
 186 
      dateformstr = getdateform(1);
 187 
   elseif all(floor(dtnumber)==0)
 188 
      dateformstr = getdateform(16);
 189 
   else
 190 
      dateformstr = getdateform(0);
 191 
   end
 192 
end 
 193 

  0.05 
      6 
 194 
S = dateformverify(dtnumber, dateformstr, islocal); 

Other subfunctions in this file are not included in this listing.