win_timezone - Allow for _dstoff timezones (#67892)

* win_timezone - Allow for _dstoff timezones

* Update win_timezone-Allow-dstoff.yml

* Added doc entry for new format

Co-authored-by: Jordan Borean <jborean93@gmail.com>
This commit is contained in:
Shachaf92 2020-03-02 00:02:38 +02:00 committed by GitHub
parent 64a2864158
commit 2e38f80f9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 8 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- "win_timezone - Allow for _dstoff timezones"

View file

@ -28,18 +28,12 @@ Try {
Exit-Json $result "Timezone '$timezone' is already set on this machine" Exit-Json $result "Timezone '$timezone' is already set on this machine"
} Else { } Else {
# Check that timezone is listed as an available timezone to the machine # Check that timezone is listed as an available timezone to the machine
$tzList = $(tzutil.exe /l) $tzList = $(tzutil.exe /l).ToLower()
If ($LASTEXITCODE -ne 0) { If ($LASTEXITCODE -ne 0) {
Throw "An error occurred when listing the available timezones." Throw "An error occurred when listing the available timezones."
} }
$tzExists = $false $tzExists = $tzList.Contains(($timezone -Replace '_dstoff').ToLower())
ForEach ($tz in $tzList) {
If ( $tz -eq $timezone ) {
$tzExists = $true
break
}
}
if (-not $tzExists) { if (-not $tzExists) {
Fail-Json $result "The specified timezone: $timezone isn't supported on the machine." Fail-Json $result "The specified timezone: $timezone isn't supported on the machine."
} }

View file

@ -20,6 +20,7 @@ options:
description: description:
- Timezone to set to. - Timezone to set to.
- 'Example: Central Standard Time' - 'Example: Central Standard Time'
- To disable Daylight Saving time, add the suffix C(_dstoff) on timezones that support this.
type: str type: str
required: yes required: yes
notes: notes:
@ -47,6 +48,10 @@ EXAMPLES = r'''
- name: Set timezone to 'Central Standard Time' (GMT-06:00) - name: Set timezone to 'Central Standard Time' (GMT-06:00)
win_timezone: win_timezone:
timezone: Central Standard Time timezone: Central Standard Time
- name: Set timezime to Pacific Standard time and disable Daylight Saving time adjustments
win_timezone:
timezone: Pacific Standard Time_dstoff
''' '''
RETURN = r''' RETURN = r'''

View file

@ -73,6 +73,17 @@
- central.timezone == 'Central Standard Time' - central.timezone == 'Central Standard Time'
when: in_check_mode when: in_check_mode
- name: Change timezone to dstoff
win_timezone:
timezone: Eastern Standard Time_dstoff
register: dstoff_result
- name: Test dstoff timezone
assert:
that:
- dstoff_result is changed
- dstoff_result.timezone == 'Eastern Standard Time_dstoff'
- name: Change timezone to GMT+666 - name: Change timezone to GMT+666
win_timezone: win_timezone:
timezone: Dag's Standard Time timezone: Dag's Standard Time