1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix ansible_distribution and weekday locale (as hinted by @nitzmahone)

This commit is contained in:
Dag Wieers 2016-06-09 12:54:08 +02:00 committed by Matt Clay
parent 36d0bac0a3
commit 35b9810e39

View file

@ -108,7 +108,7 @@ Set-Attr $result.ansible_facts "ansible_system_description" ([string] $win32_os.
Set-Attr $result.ansible_facts "ansible_system_vendor" $win32_cs.Manufacturer
Set-Attr $result.ansible_facts "ansible_os_family" "Windows"
Set-Attr $result.ansible_facts "ansible_os_name" ($win32_os.Name.Split('|')[0]).Trim()
Set-Attr $result.ansible_facts "ansible_distribution" $osversion.VersionString
Set-Attr $result.ansible_facts "ansible_distribution" $win32_os.Caption
Set-Attr $result.ansible_facts "ansible_distribution_version" $osversion.Version.ToString()
Set-Attr $result.ansible_facts "ansible_distribution_major_version" $osversion.Version.Major.ToString()
Set-Attr $result.ansible_facts "ansible_kernel" $osversion.Version.ToString()
@ -127,8 +127,6 @@ Set-Attr $result.ansible_facts "ansible_user_id" $env:username
Set-Attr $result.ansible_facts "ansible_user_uid" ([int] $user.User.Value.Substring(42))
Set-Attr $result.ansible_facts "ansible_user_sid" $user.User.Value
# Use English locale
$culture = New-Object System.Globalization.CultureInfo('en-US')
$date = New-Object psobject
$datetime = (Get-Date)
$datetime_utc = $datetime.ToUniversalTime()
@ -146,7 +144,8 @@ Set-Attr $date "second" $datetime.ToString("ss")
Set-Attr $date "time" $datetime.ToString("HH:mm:ss")
Set-Attr $date "tz_offset" $datetime.ToString("zzzz")
Set-Attr $date "tz" ([System.TimeZoneInfo]::Local.Id)
Set-Attr $date "weekday" $datetime.ToString("dddd", $culture)
# Ensure that the weekday is in English
Set-Attr $date "weekday" $datetime.ToString("dddd", [System.Globalization.CultureInfo]::InvariantCulture)
Set-Attr $date "weekday_number" (Get-Date -UFormat "%w")
Set-Attr $date "weeknumber" (Get-Date -UFormat "%W")
Set-Attr $date "year" $datetime.ToString("yyyy")