from datetime import timedelta
from enum import Enum
from tkinter import *
from tkinter import ttk
import typer

from sqlmodel import Session


class Status(str, Enum):
    """Status"""
    to_do = 'to do'
    doing = 'doing'
    done = 'done'


def round_timedelta(delta: timedelta):
    """round timedelta object"""
    seconds = round(delta.total_seconds())
    if seconds >= 3600:
        hours = round(seconds/3600)
        seconds += - hours*3600
    else:
        hours = 0
    if seconds >= 60:
        minutes = round(seconds/60)
        seconds += - minutes * 60
    else:
        minutes = 0
    if hours < 10:
        hours = '0' + str(hours)
    if minutes < 10:
        minutes = '0' + str(minutes)

    return f'{hours}:{minutes}'


def list_query(engine, query):
    """Calculate duration of a task"""
    with 