parse_time

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

Given a time string will parse and return a datetime object. Similar to the anytim function in IDL. utime – Time since epoch 1 Jan 1979

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 (datetime) – DateTime corresponding to input date string
  • Note
  • If time_string is an instance of float, then it is assumed to be in utime 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)