feat(aurora): added timedelta_from_string() function
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 31s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 50s

This commit is contained in:
Seaswimmer 2024-06-04 23:31:52 -04:00
parent 74d122a2e7
commit 78630dc317
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F
2 changed files with 9 additions and 3 deletions

View file

@ -194,6 +194,13 @@ def timedelta_from_relativedelta(relativedelta: rd) -> timedelta:
then = now - relativedelta
return now - then
def timedelta_from_string(string: str) -> timedelta:
"""Converts a string to a timedelta object."""
from .logger import logger
hours, minutes, seconds = map(int, string.split(":"))
logger.debug("%s | hours: %s, minutes: %s, seconds: %s", string, hours, minutes, seconds)
return timedelta(hours=hours, minutes=minutes, seconds=seconds)
def timedelta_to_string(timedelta: timedelta) -> str:
"""Converts a timedelta object to a string."""
hours, remainder = divmod(timedelta.seconds, 3600)