function update(h)

%% Updates the datenum to reflect the current state of the calendar dialog

%% Get the current year
year = str2num(get(h.Handles.yearCombo,'string'));
if isempty(year)
    errordlg('Invalid data','modal')
    return
end

%% Get the current month
month = get(h.Handles.monthCombo,'value');

%% Get the current date
row = h.Table.getTable.getSelectedRows;
col = h.Table.getTable.getSelectedColumns;
date = 1;
if ~isempty(row) && ~isempty(col) && row>=1 && col>=0
    valstr = h.Table.getTable.getValueAt(row,col);
    if ~isempty(valstr) 
        date = str2num(valstr);
    end
end

%% Get the time vector
try
    timevec = datevec(get(h.Handles.EDITTime,'String'));
catch
    errordlg('Invalid time','Time Series Tool','modal')
    set(h.Handles.EDITTime,'String','00:00:00')
    return
end

%% Set the datenum prop who's listener will update the table to reflect 
%% any change in month or year
newdatenum = datenum([year,month,date,timevec(4:end)]);
if abs(h.DateNum-newdatenum)>0
   h.DateNum = newdatenum;
end
