salt.modules.mac_timezone

Module for editing date/time settings on macOS

New in version 2016.3.0.

salt.modules.mac_timezone.get_date()

Displays the current date

Returns:

the system date

Return type:

str

CLI Example:

salt '*' timezone.get_date
salt.modules.mac_timezone.get_hwclock()

Get current hardware clock setting (UTC or localtime)

CLI Example:

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

Displays the current time zone offset

Returns:

The current time zone offset

Return type:

str

CLI Example:

salt '*' timezone.get_offset
salt.modules.mac_timezone.get_time()

Get the current system time.

Returns:

The current time in 24 hour format

Return type:

str

CLI Example:

salt '*' timezone.get_time
salt.modules.mac_timezone.get_time_server()

Display the currently set network time server.

Returns:

the network time server

Return type:

str

CLI Example:

salt '*' timezone.get_time_server
salt.modules.mac_timezone.get_using_network_time()

Display whether network time is on or off

Returns:

True if network time is on, False if off

Return type:

bool

CLI Example:

salt '*' timezone.get_using_network_time
salt.modules.mac_timezone.get_zone()

Displays the current time zone

Returns:

The current time zone

Return type:

str

CLI Example:

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

Displays the current time zone abbreviated code

Returns:

The current time zone code

Return type:

str

CLI Example:

salt '*' timezone.get_zonecode
salt.modules.mac_timezone.list_zones()

Displays a list of available time zones. Use this list when setting a time zone using timezone.set_zone

Returns:

a list of time zones

Return type:

list

CLI Example:

salt '*' timezone.list_zones
salt.modules.mac_timezone.set_date(date)

Set the current month, day, and year

Parameters:

date (str) --

The date to set. Valid date formats are:

  • %m:%d:%y

  • %m:%d:%Y

  • %m/%d/%y

  • %m/%d/%Y

Returns:

True if successful, False if not

Return type:

bool

Raises:

SaltInvocationError on Invalid Date format

Raises:

CommandExecutionError on failure

CLI Example:

salt '*' timezone.set_date 1/13/2016
salt.modules.mac_timezone.set_hwclock(clock)

Sets the hardware clock to be either UTC or localtime

CLI Example:

salt '*' timezone.set_hwclock UTC
salt.modules.mac_timezone.set_time(time)

Sets the current time. Must be in 24 hour format.

Parameters:

time (str) -- The time to set in 24 hour format. The value must be double quoted. ie: '"17:46"'

Returns:

True if successful, False if not

Return type:

bool

Raises:

SaltInvocationError on Invalid Time format

Raises:

CommandExecutionError on failure

CLI Example:

salt '*' timezone.set_time '"17:34"'
salt.modules.mac_timezone.set_time_server(time_server='time.apple.com')

Designates a network time server. Enter the IP address or DNS name for the network time server.

Parameters:

time_server -- IP or DNS name of the network time server. If nothing is passed the time server will be set to the macOS default of 'time.apple.com'

Type:

str

Returns:

True if successful, False if not

Return type:

bool

Raises:

CommandExecutionError on failure

CLI Example:

salt '*' timezone.set_time_server time.acme.com
salt.modules.mac_timezone.set_using_network_time(enable)

Set whether network time is on or off.

Parameters:

enable -- True to enable, False to disable. Can also use 'on' or 'off'

Type:

str bool

Returns:

True if successful, False if not

Return type:

bool

Raises:

CommandExecutionError on failure

CLI Example:

salt '*' timezone.set_using_network_time True
salt.modules.mac_timezone.set_zone(time_zone)

Set the local time zone. Use timezone.list_zones to list valid time_zone arguments

Parameters:

time_zone (str) -- The time zone to apply

Returns:

True if successful, False if not

Return type:

bool

Raises:

SaltInvocationError on Invalid Timezone

Raises:

CommandExecutionError on failure

CLI Example:

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

Compares the given timezone name with the system timezone name.

Returns:

True if they are the same, False if not

Return type:

bool

CLI Example:

salt '*' timezone.zone_compare America/Boise