mpas_analysis.shared.timekeeping.utility.datetime_to_days

mpas_analysis.shared.timekeeping.utility.datetime_to_days(dates, calendar='gregorian', referenceDate='0001-01-01')[source]

Given date(s), a calendar and a reference date, returns the days since the reference date, either as a single float or an array of floats.

Parameters
  • datetime (instance or array-like of datetime.datetime) – The date(s) to be converted to days since referenceDate on the given calendar.

  • calendar ({'gregorian', 'gregorian_noleap'}, optional) – A calendar to be used to convert days to a datetime.datetime object.

  • referenceDate (str, optional) –

    A reference date of the form:

    0001-01-01
    0001-01-01 00:00:00
    

Returns

days (float or array of floats) – The days since referenceDate on the given calendar.

Raises

ValueError – If an invalid datetimes, referenceDate or calendar is supplied.