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 givencalendar
.calendar ({'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 givencalendar
.- Raises:
ValueError – If an invalid
datetimes
,referenceDate
orcalendar
is supplied.