Home > freetb4matlab > time > datesplit.m

datesplit

PURPOSE ^

% Split a date string into the Year, Month, Day, hour, minute, and

SYNOPSIS ^

function [y, m, d, h, mi, s] = datesplit(ds, P)

DESCRIPTION ^

% -*- texinfo -*-
% @deftypefn {Function File} {Y =} datesplit(date, P)
% @deftypefnx {Function File} {[Y,M,D,h,m,s] =} datesplit(date, P)
% Split a date string into the Year, Month, Day, hour, minute, and
% second.  This routine tries to be as forgiving as possible to the
% date input while requiring that the date is not ambiguous.
%
% Anywhere possible where it would not be ambiguous, efforts were made
% to make times possible with seconds and AM/PM as optional.  Also,
% along the same lines, where possible, commas were allowed with
% spaces, and the year/month/day separators were allowed as period (.),
% slash (/), and dash (-).  Not all format possibilities are shown in
% the following table, but a date like @code{dd-mmm-yyyy HH:MM:SS} is
% parsed just as well as @code{d/mmm.yyyy,  ,H:MM, AM}.
%
% Supported @code{date} formats include (the same as datestr):
% @multitable @columnfractions 0.1 0.45 0.45
% @item @strong{Code} @tab @strong{Format} @tab @strong{Example}
% @item  0  @tab dd-mmm-yyyy HH:MM:SS    @tab 07-Sep-2000 15:38:09
% @item  1  @tab dd-mmm-yyyy             @tab 07-Sep-2000 
% @item  2  @tab mm/dd/yy                @tab 09/07/00 
% @item  3  @tab mmm                     @tab Sep 
% @item  6  @tab mm/dd                   @tab 09/13 
% @item 10  @tab yyyy                    @tab 2000 
% @item 12  @tab mmmyy                   @tab Sep00 
% @item 13  @tab HH:MM:SS                @tab 15:38:09 
% @item 14  @tab HH:MM:SS PM             @tab 03:38:09 PM
% @item 15  @tab HH:MM                   @tab 15:38 
% @item 16  @tab HH:MM PM                @tab 03:38 PM 
% @item 17  @tab QQ-YY                   @tab Q3-00
% @item 19  @tab dd/mm                   @tab 13/03
% @item 20  @tab dd/mm/yy                @tab 13/03/95
% @item 21  @tab mmm.dd.yyyy HH:MM:SS    @tab Mar.03.1962 13:53:06
% @item 22  @tab mmm.dd.yyyy             @tab Mar.03.1962
% @item 23  @tab mm/dd/yyyy              @tab 03/13/1962
% @item 24  @tab dd/mm/yyyy              @tab 12/03/1962
% @item 25  @tab yy/mm/dd                @tab 95/03/13
% @item 26  @tab yyyy/mm/dd              @tab 1995/03/13
% @item 27  @tab QQ-YYYY                 @tab Q4-2132
% @item 28  @tab mmmyyyy                 @tab Mar2047
% @item 29  @tab yyyymmdd                @tab 20470313
% @item 30  @tab yyyymmddTHHMMSS         @tab 20470313T132603
% @item 31  @tab yyyy-mm-dd HH:MM:SS     @tab 1047-03-13 13:26:03
% @end multitable
%
% The parameter @code{P} is needed to convert date strings with 2 digit
% years into dates with 4 digit years.  2 digit years are assumed to be
% between @code{P} and @code{P+99}. If @code{P} is not given then the 
% current year - 50 is used, so that dates are centered on the present.
% For birthdates, you would want @code{P} to be current year - 99.  For
% appointments, you would want @code{P} to be current year.
%
% This function makes no strong attempt to verify the accuracy of the
% numbers that it returns in that it doesn't (currently) check to see
% that you're not trying to use the date Feb 30.  When applicable, it
% tries to make your input work, though.  It will try to determine if
% you're using the date "03/13/95" that the date is "March 13, 1995",
% but if there is doubt, datesplit will return an error instead of
% trying to guess the wrong value.
%
% @seealso{date,clock,now,datestr,datenum,calendar,weekday} 
% @end deftypefn

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Fri 22-May-2009 15:13:00 by m2html © 2003