

def extract_time(element):
    ' return a datetime object based on a gml text string\n\nex:\n<gml:beginPosition>2006-07-27T21:10:00Z</gml:beginPosition>\n<gml:endPosition indeterminatePosition="now"/>\n\nIf there happens to be a strange element with both attributes and text,\nuse the text.\nex: <gml:beginPosition indeterminatePosition="now">2006-07-27T21:10:00Z</gml:beginPosition>\nWould be 2006-07-27T21:10:00Z, not \'now\'\n\n'
    if (element is None):
        return None
    try:
        dt = parser.parse(element.text)
    except Exception:
        att = testXMLValue(element.attrib.get('indeterminatePosition'), True)
        if (att and (att == 'now')):
            dt = datetime.utcnow()
            dt.replace(tzinfo=pytz.utc)
        else:
            dt = None
    return dt

dataset/ETHPy150Open geopython/OWSLib/owslib/util.py extract_time/original