date list to dates converter

I need a function which will take an N by 3 or N by 6 array, where the columns are year, month, day in the first case and those three plus hours, minutes, and seconds in the second case and convert them to matplotlib dates. This would work the same as the MATLAB datenum() function.

Thanks in advance.