Created
March 14, 2017 16:22
-
-
Save Eitol/7fe6957d2ae58665a28438fc4ae9c29e to your computer and use it in GitHub Desktop.
Return the system timezone in linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def get_system_timezone() -> str: | |
""" | |
Retorna el timezone del sistema | |
:return: Ej: America/Caracas | |
""" | |
str_timezone = subprocess.getoutput('ls /etc/ -l | grep localtime | awk \'{print $11}\'') | |
assert str_timezone is not None and len(str_timezone) and \ | |
str_timezone.find('../usr/share/zoneinfo/') != -1, "TIMEZONE_GET_ERROR:" | |
str_timezone = str_timezone.replace('../usr/share/zoneinfo/', '') | |
assert len(str_timezone), "INVALID_SYSTEM_TIMEZONE" | |
return str_timezone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment