function out = dategapdetection(date_prev,date_curr)

if date_curr == date_prev + 1
    out = 0; % no gap
    break;
end;

year_prev = floor(date_prev/10000);
year_curr = floor(date_curr/10000);
month_prev = floor (date_prev/100)-year_prev*100;
month_curr = floor (date_curr/100)-year_curr*100;

if month_curr == month_prev
    out = 1;
    break;
end;

if month_curr ~= month_prev & eomday(year_prev,month_prev) ~= date_prev-(year_prev*100+month_prev)*100
    out = 1;
    break;
end;

out = 0;