This commit is contained in:
Ayush Saini 2024-11-22 19:30:54 +05:30
commit cc7c7450d2
12 changed files with 354 additions and 24 deletions

View file

@ -48,15 +48,18 @@ def commit(data: dict) -> None:
if is_invalid_time_format(data['autoNightMode']['startTime']) or is_invalid_time_format(data['autoNightMode']['endTime']):
data['autoNightMode']['startTime'] = "18:30"
data['autoNightMode']['endTime'] = "6:30"
print("Invalid time setting , resetting night mode time")
print("Invalid time setting , resetting night mode time")
with open(SETTINGS_PATH, mode="w", encoding="utf-8") as setting_file:
json.dump(data, setting_file, indent=4)
# settings updated ok now update the cache
refresh_cache()
def is_invalid_time_format(time_string, time_format='%H:%M'):
try:
datetime.datetime.strptime(time_string, time_format)
return False
except ValueError:
return True
return True