is_time

sunpy.time.is_time(time_string, time_format='')[source] [edit on github]

Returns true if the input is a valid date/time representation

Parameters:
  • time_string ([ int, float, time_string, datetime ]) – Date to parse which can be either time_string, int, datetime object.
  • time_format ([ basestring, utime, datetime ]) – Specifies the format user has provided the time_string in.
Returns:

out (bool) – True if can be parsed by parse_time

Notes

If time_string is an instance of float, then it is assumed to be in unix time format.

Examples

>>> import sunpy.time
>>> sunpy.time.parse_time('2012/08/01')
datetime.datetime(2012, 8, 1, 0, 0)
>>> sunpy.time.parse_time('2005-08-04T00:01:02.000Z')
datetime.datetime(2005, 8, 4, 0, 1, 2)