51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
class Util:
|
|
@staticmethod
|
|
def format_seconds(seconds):
|
|
hours = None
|
|
minutes = seconds / 60
|
|
if minutes >= 1:
|
|
if minutes >= 60:
|
|
hours = int(minutes / 60)
|
|
minutes = int(minutes % 60)
|
|
else:
|
|
minutes = int(minutes)
|
|
seconds = seconds % 60
|
|
else:
|
|
minutes = None
|
|
|
|
time = ""
|
|
if hours is not None and hours != 0:
|
|
time += str(hours) + "h"
|
|
if minutes is not None and minutes != 0:
|
|
time += str(minutes) + "m"
|
|
if seconds is not None and seconds != 0:
|
|
time += str(seconds) + "s"
|
|
|
|
return time
|
|
|
|
@staticmethod
|
|
def format_time_to_seconds(time: str) -> int:
|
|
seconds = 0
|
|
|
|
hours = time.split("h")
|
|
if len(hours) > 1:
|
|
seconds += (60 * 60 * int(hours.pop(0)))
|
|
time = hours.pop(0)
|
|
|
|
minutes = time.split("m")
|
|
if len(minutes) > 1:
|
|
seconds += (60 * int(minutes.pop(0)))
|
|
time = minutes.pop(0)
|
|
|
|
seconds += int(time[0:-1]) if len(time) > 0 else 0
|
|
|
|
return seconds
|
|
|
|
@staticmethod
|
|
def get_default_button_color():
|
|
return "#3a7ebf", "#1f538d"
|
|
|
|
@staticmethod
|
|
def get_default_active_button_color():
|
|
return "green", "green"
|