mpas_analysis.shared.timekeeping.utility.string_to_datetime

mpas_analysis.shared.timekeeping.utility.string_to_datetime(dateString)[source]

Given a date string and a calendar, returns a datetime.datetime

Parameters:

dateString (string) –

A date and time 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.

Returns:

datetime (A datetime.datetime object)

Raises:

ValueError – If an invalid dateString is supplied.