def str_to_time(timestr, time_format=TIME_FORMAT):
if not timestr:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>try:<EOL><INDENT>then = time.strptime(timestr, time_format)<EOL><DEDENT>except ValueError:  <EOL><INDENT>try:<EOL><INDENT>elem = TIME_FORMAT_WITH_FRAGMENT.match(timestr)<EOL><DEDENT>except Exception as exc:<EOL><INDENT>print >> sys.stderr, "<STR_LIT>" % (exc, timestr)<EOL>raise<EOL><DEDENT>then = time.strptime(elem.groups()[<NUM_LIT:0>] + "<STR_LIT>", TIME_FORMAT)<EOL><DEDENT>return time.gmtime(calendar.timegm(then))<EOL>
:param timestr:
:param time_format:
:return: UTC time