%**************************************************************************
%This function gets the date from the header of the
%undulator data file.
%
%Input:
%header, header from the undulator data file
%
%Output:
%dd, day
%mm, month
%yyyy, year
%
%Zachary Wolf, 4/6/09

function [dd, mm, yyyy] = util_get_date_header(header)

%Initialize
dd = 0;
mm = 0;
yyyy = 0;
        
%Find the date
[r, c] = size(header);
for ii = 1 : c
    if strfind(header{ii}, 'Date:') > 0
        date_str = header{ii};
        break;
    end
end

%Get the date
[date_array, count] = sscanf(date_str, 'Date: %2d-%2d-%4d');
if count == 3
    date_array = date_array';
    mm = date_array(1);
    dd = date_array(2);
    yyyy = date_array(3);
else
    error(['Could not read date from header: ', date_str]);
end

%Done
