#NEWLINE# def str_to_time( timestr , time_format = TIME_FORMAT ) : #NEWLINE# #INDENT# '\n\n    :param timestr:\n    :param time_format:\n    :return: UTC time\n    ' #NEWLINE# if ( not timestr ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# then = time . strptime ( timestr , then ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# elem = TIME_FORMAT_WITH_FRAGMENT . match ( timestr ) #NEWLINE# #UNINDENT# except Exception as exc : #NEWLINE# #INDENT# ( ( print >> sys . stderr ) , ( 'Exception: %s on %s' % ( exc , timestr ) ) ) #NEWLINE# raise #NEWLINE# #UNINDENT# then = time . strptime ( ( elem . groups ( ) [ 0 ] + 'Z' ) , TIME_FORMAT ) #NEWLINE# #UNINDENT# return time . gmtime ( calendar . timegm ( then ) )