def _get_localzone():
    pipe = subprocess.Popen(
        "systemsetup -gettimezone",
        shell=True,
        stderr=subprocess.PIPE,
        stdout=subprocess.PIPE
    )
    tzname = pipe.stdout.read().replace(b'Time Zone: ', b'').strip()

    if not tzname or tzname not in pytz.all_timezones_set:
        # link will be something like /usr/share/zoneinfo/America/Los_Angeles.
        link = os.readlink("/etc/localtime")
        tzname = link[link.rfind("zoneinfo/") + 9:]
    return pytz.timezone(tzname)
dataset/ETHPy150Open Southpaw-TACTIC/TACTIC/3rd_party/site-packages/tzlocal_olson/darwin.py/_get_localzone/original