Skip to content
utils.py 375 B
Newer Older
Wei Shoulin's avatar
Wei Shoulin committed
from datetime import datetime
    
def is_valid_datetime_format(date_str: str, format='%Y-%m-%d %H:%M:%S') -> bool:
    try:
        datetime.strptime(date_str, format)
        return True
    except ValueError:
Wei Shoulin's avatar
Wei Shoulin committed
        raise ValueError(f"Incorrect data format, should be {format}")
    
def get_current_time() -> str:
    return datetime.now().strftime('%Y-%m-%d %H:%M:%S')