def str_to_time(timestr, time_format=TIME_FORMAT):
    """

    :param timestr:
    :param time_format:
    :return: UTC time
    """
    if not timestr:
        return 0
    try:
        then = time.strptime(timestr, time_format)
    except __HOLE__:  # assume it's a format problem
        try:
            elem = TIME_FORMAT_WITH_FRAGMENT.match(timestr)
        except Exception as exc:
            print >> sys.stderr, "Exception: %s on %s" % (exc, timestr)
            raise
        then = time.strptime(elem.groups()[0] + "Z", TIME_FORMAT)

    return time.gmtime(calendar.timegm(then))
dataset/ETHPy150Open rohe/pyoidc/src/oic/utils/time_util.py/str_to_time