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:
parent
64a2864158
commit
2e38f80f9e
4 changed files with 21 additions and 8 deletions
3
changelogs/fragments/win_timezone-Allow-dstoff.yml
Normal file
3
changelogs/fragments/win_timezone-Allow-dstoff.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- "win_timezone - Allow for _dstoff timezones"
|
|
@ -28,18 +28,12 @@ Try {
|
|||
Exit-Json $result "Timezone '$timezone' is already set on this machine"
|
||||
} Else {
|
||||
# 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) {
|
||||
Throw "An error occurred when listing the available timezones."
|
||||
}
|
||||
|
||||
$tzExists = $false
|
||||
ForEach ($tz in $tzList) {
|
||||
If ( $tz -eq $timezone ) {
|
||||
$tzExists = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
$tzExists = $tzList.Contains(($timezone -Replace '_dstoff').ToLower())
|
||||
if (-not $tzExists) {
|
||||
Fail-Json $result "The specified timezone: $timezone isn't supported on the machine."
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ options:
|
|||
description:
|
||||
- Timezone to set to.
|
||||
- 'Example: Central Standard Time'
|
||||
- To disable Daylight Saving time, add the suffix C(_dstoff) on timezones that support this.
|
||||
type: str
|
||||
required: yes
|
||||
notes:
|
||||
|
@ -47,6 +48,10 @@ EXAMPLES = r'''
|
|||
- name: Set timezone to 'Central Standard Time' (GMT-06:00)
|
||||
win_timezone:
|
||||
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'''
|
||||
|
|
|
@ -73,6 +73,17 @@
|
|||
- central.timezone == 'Central Standard Time'
|
||||
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
|
||||
win_timezone:
|
||||
timezone: Dag's Standard Time
|
||||
|
|
Loading…
Reference in a new issue