Esempio n. 1
0
def contime(s):
    """Process a string into time."""
    if len(re.findall("0000*T", s)) > 0:
        return None
    try:
        ts = datetime.strptime(s, "%y%m%dT%H%MZ")
        return ts.replace(tzinfo=timezone.utc)
    except Exception as err:
        LOG.exception(err)
        return None
Esempio n. 2
0
def contime(text):
    """Convert text into a UTC datetime."""
    # The 0000 is the standard VTEC undefined time
    if text.startswith("0000"):
        return None
    try:
        ts = datetime.strptime(text, "%y%m%dT%H%MZ")
    except Exception as err:
        LOG.exception(err)
        return None
    # NWS has a bug sometimes whereby 1969 or 1970s timestamps are emitted
    if ts.year < 1971:
        return None
    return ts.replace(tzinfo=timezone.utc)