How to use the tzlocal.windows_tz function in tzlocal

To help you get started, we’ve selected a few tzlocal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jkoelker / python-eoddata / eoddata / datareader.py View on Github external
def exchange_tz(self, exchange, exchanges=None):
        # NOTE(jkoelker) EODData's service is windows based, convert times here
        if exchanges is None:
            exchanges = self.exchanges()
        exchange_tz = exchanges[exchange]['time_zone']
        return pytz.timezone(windows_tz.tz_names[exchange_tz])
github rackerlabs / python-cloudbackup-sdk / cloudbackup / utils / tz.py View on Github external
if WindowsZoneName is True, then it returns the name used by the Microsoft Windows Platform
    otherwise it returns the Olsen name (used by all other platforms)

    Note: this needs to get tested on Windows
    """
    log = logging.getLogger(__name__)
    localzone = tzlocal.get_localzone()
    if localzone is None:
        log.error('tzlocal did not provide a time zone configuration')
        raise pytz.UnknownTimeZoneError('Cannot find  any time zone configuration')
    else:
        olsen_name = localzone.zone
        if WindowsZoneName:
            try:
                windows_name = tzlocal.windows_tz.tz_win[olsen_name]
                log.info('Mappped Olsen Time Zone Name (' + olsen_name + ') to Windows Time Zone Name (' + windows_name + ')')
                return windows_name
            except LookupError:
                log.error('Unable to map Olsen Time Zone Name (' + olsen_name + ') to Windows Time Zone Name')
                return 'Unknown'
        else:
            return olsen_name
github cloudbase / cloudbase-init / cloudbaseinit / osutils / windows.py View on Github external
def set_timezone(self, timezone_name):
        windows_name = windows_tz.tz_win.get(timezone_name)
        if not windows_name:
            raise exception.CloudbaseInitException(
                "The given timezone name is unrecognised: %r" % timezone_name)
        timezone.Timezone(windows_name).set(self)