salt.modules.win_timezone

Module for managing timezone on Windows systems.

class salt.modules.win_timezone.TzMapper(unix_to_win)
add(k, v)
get_unix(key, default=None)
get_win(key, default=None)
list_unix()
list_win()
remove(k)
salt.modules.win_timezone.get_hwclock()

Get current hardware clock setting (UTC or localtime)

Note

The hardware clock is always local time on Windows so this will always return "localtime"

CLI Example:

salt '*' timezone.get_hwclock
salt.modules.win_timezone.get_offset()

Get current numeric timezone offset from UTC (i.e. -0700)

Returns

Offset from UTC

Return type

str

CLI Example:

salt '*' timezone.get_offset
salt.modules.win_timezone.get_zone()

Get current timezone (i.e. America/Denver)

Returns

Timezone in unix format

Return type

str

CLI Example:

salt '*' timezone.get_zone
salt.modules.win_timezone.get_zonecode()

Get current timezone (i.e. PST, MDT, etc)

Returns

An abbreviated timezone code

Return type

str

CLI Example:

salt '*' timezone.get_zonecode
salt.modules.win_timezone.list(unix_style=True)

Return a list of Timezones that this module supports. These can be in either Unix or Windows format.

New in version 2018.3.3.

Parameters

unix_style (bool) -- True returns Unix-style timezones. False returns Windows-style timezones. Default is True

Returns

A list of supported timezones

Return type

list

CLI Example:

# Unix-style timezones
salt '*' timezone.list

# Windows-style timezones
salt '*' timezone.list unix_style=False
salt.modules.win_timezone.set_hwclock(clock)

Sets the hardware clock to be either UTC or localtime

Note

The hardware clock is always local time on Windows so this will always return False

CLI Example:

salt '*' timezone.set_hwclock UTC
salt.modules.win_timezone.set_zone(timezone)

Sets the timezone using the tzutil.

Parameters

timezone (str) -- A valid timezone

Returns

True if successful, otherwise False

Return type

bool

Raises

CommandExecutionError -- If invalid timezone is passed

CLI Example:

salt '*' timezone.set_zone 'America/Denver'
salt.modules.win_timezone.zone_compare(timezone)

Compares the given timezone with the machine timezone. Mostly useful for running state checks.

Parameters

timezone (str) -- The timezone to compare. This can be in Windows or Unix format. Can be any of the values returned by the timezone.list function

Returns

True if they match, otherwise False

Return type

bool

Example:

salt '*' timezone.zone_compare 'America/Denver'