diff --git a/framework/python/src/common/util.py b/framework/python/src/common/util.py index 3ef8827dc..88cee862a 100644 --- a/framework/python/src/common/util.py +++ b/framework/python/src/common/util.py @@ -21,6 +21,7 @@ import typing as t import netifaces from common import logger +import tzlocal LOGGER = logger.get_logger('util') @@ -153,3 +154,14 @@ def diff_dicts(d1: t.Dict[t.Any, t.Any], d2: t.Dict[t.Any, t.Any]) -> t.Dict: if items_added: diff['items_added'] = items_added return diff + + +def get_system_timezone() -> str: + """Returns the local timezone of the system.""" + try: + local_timezone = tzlocal.get_localzone() + return str(local_timezone) + except Exception as e: + LOGGER.error(f'Error getting local timezone: {e}') + return 'UTC' + diff --git a/framework/requirements.txt b/framework/requirements.txt index 5361caef1..6c2ddafdc 100644 --- a/framework/requirements.txt +++ b/framework/requirements.txt @@ -44,3 +44,6 @@ APScheduler==3.10.4 Jinja2==3.1.6 beautifulsoup4==4.12.3 html5lib==1.1 + +# Requirements for timezone handling +tzlocal==5.4.3 \ No newline at end of file diff --git a/modules/test/base/python/requirements.txt b/modules/test/base/python/requirements.txt index f00be89cb..3055c10ec 100644 --- a/modules/test/base/python/requirements.txt +++ b/modules/test/base/python/requirements.txt @@ -10,3 +10,7 @@ netifaces==0.11.0 # Requirements for reports generation Jinja2==3.1.6 + +# Requirements for timezone handling +tzlocal==5.4.3 +