| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 | import uuidfrom datetime import datetimeimport jwtdef datetime2timestamp(value: datetime):    if not value:        return None    return value.timestamp()def str2datetime(value: str):    if not value:        return None    return datetime.fromisoformat(value)def is_valid_datetime(date_str, format="%Y-%m-%d %H:%M:%S"):    if not date_str or not isinstance(date_str, str):        return False    try:        datetime.strptime(date_str, format)        return True    except ValueError:        return Falsedef random_uuid() -> str:    return "ml-" + str(uuid.uuid4()).replace("-", "")def verify_jwt_expiration(token):    decoded_token = jwt.decode(        token, options={"verify_signature": False, "verify_exp": False}    )    expiration_time = datetime.fromtimestamp(decoded_token["exp"])    current_time = datetime.now()    print(        "time=>time=>time=>time=>time=>time=>time=>time=>time=>time=>time=>time=>time=>time=>time=>time=>time=>"    )    print(f"expiration_time: {expiration_time}")    print(f"expiration_time: {current_time}")    return current_time < expiration_time
 |