mpas_analysis.shared.timekeeping.utility.string_to_days_since_date

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

Given a date string or an array-like of date strings, a reference date string, and a calendar, returns the number of days (as a float or numpy.array of floats) since the reference date

Parameters
dateStringsstr or array-like of str

A date and time (or array of date/times) in one of the following formats:

YYYY-MM-DD hh:mm:ss
YYYY-MM-DD hh.mm.ss
YYYY-MM-DD SSSSS
DDD hh:mm:ss
DDD hh.mm.ss
DDD SSSSS
hh.mm.ss
hh:mm:ss
YYYY-MM-DD
YYYY-MM
SSSSS

Note: either underscores or spaces can be used to separate the date from the time portion of the string.

calendar: {‘gregorian’, ‘gregorian_noleap’}, optional

The name of one of the calendars supported by MPAS cores

referenceDatestr, optional

A reference date of the form:

0001-01-01
0001-01-01 00:00:00
Returns
daysfloat or numpy.array of floats

The number of days since referenceDate for each date in dateString

Raises
ValueError

If an invalid dateString or calendar is supplied.