Пример #1
0
def datetimeFromDateStr3(ds):
    st = None
    if ds.endswith("T00:00:00.000Z"):
        st = time.strptime(ds, "%Y-%m-%dT00:00:00.000Z")
        return datetimeFrom(st)
    elif ds.endswith("T00:00:00Z"):
        st = time.strptime(ds, "%Y-%m-%dT00:00:00Z")
        return datetimeFrom(st)
    elif ds.endswith(" 00:00:00+00:00"):
        st = time.strptime(ds, "%Y-%m-%d 00:00:00+00:00")
        return datetimeFrom(st)
    elif ds.endswith(" 12:00:00 AM"):
        st = time.strptime(ds, "%m/%d/%Y 12:00:00 AM")
        return datetimeFrom(st)
    elif ds.endswith(" 00:00:00") and ds[4] == '/':
        st = time.strptime(ds, "%Y/%m/%d 00:00:00")
        return datetimeFrom(st)
    elif len(ds) == 10:
        st = time.strptime(ds, "%Y-%m-%d")
        return datetimeFrom(st)
    else:
        print(ds)
        dt = dateutil.parser.parse(ds)
        dt = dt.replace(tzinfo=None)
        return dt
Пример #2
0
def datetimeFromAnyDateStr(s) -> str:
    dt = pd.to_datetime(s)
    dt = dt.replace(tzinfo=None)
    #dt2 = datetimeFromAnyDateStr2(s)
    #print(s)
    #if cd.dayFromDate(dt) != cd.dayFromDate(dt2):
    #    print("bad date parse '{}' dt={} dt2={}".format(s,dt,dt2))
    return dt
Пример #3
0
def datetimeFromAnyDateStr2(s) -> str:
    dt = dateutil.parser.parse(s)
    dt = dt.replace(tzinfo=None)
    return dt