function [year_month] = month2date(month);%,dayin,PlusMinus1)
%Transforms the month (xbt data) to the possible values
%of altimetry data
%Input Variables: month =/ex. aug04
%                 dayin = 01-31 (day of the month)
%                 PlusMinus1[0] = 1,0,-1 (next,current,previous month)
%month
%Usage:
%[year_month_day] = month2date(month)

if nargin < 3; PlusMinus1 = 0; end

mths = {'jan';'feb';'mar';'apr';'may';'jun';'jul';
        'aug';'sep';'oct';'nov';'dec'};
mthsnum = {'01';'02';'03';'04';'05';'06';'07';'08';'09';'10';'11';'12'};

%Get the month and year
for f = 1:size(month,1)
    
month_m = month(f,1:3);
month_y = month(f,4:end);

%Include the century
if (str2double(month_y) < 20), 
    month_y = strcat('20',month_y);
else
    month_y = strcat('19',month_y);
end

[a] = find(strcmpi(month_m,mths));

%Include previous month or next month, depending on you request (PlusMinus1)
%Correct if a>12 and a<1
Correc = false;
if (a > 12), a = a-12;
    Correc = true;
    year_pm = str2double(month_y)+1;
elseif (a < 1),  a = a+12;
    Correc = true;
    year_pm = str2double(month_y)-1;
end
if Correc
     month_y = num2str(year_pm);
end


year_month(f,:) = strcat(month_y,mthsnum{a});

end
return
