win_dsc - be more lenient with datetime parsing (#59703)

* win_dsc - be more lenient with datetime parsing

* Remove l that shouldn't be there

(cherry picked from commit 04ec47bdf1)
This commit is contained in:
Jordan Borean 2019-07-31 08:45:37 +10:00 committed by Toshio Kuratomi
parent 8af9c9ccc9
commit aabc0aff57
3 changed files with 6 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- win_dsc - Be more leniant around the accepted DateTime values for backwards compatibility - https://github.com/ansible/ansible/issues/59667

View file

@ -19,11 +19,7 @@ Function ConvertTo-ArgSpecType {
$arg_type = switch($CimType) {
Boolean { "bool" }
Char16 { [Func[[Object], [Char]]]{ [System.Char]::Parse($args[0].ToString()) } }
DateTime { [Func[[Object], [DateTime]]]{
# o == ISO 8601 format
[System.DateTime]::ParseExact($args[0].ToString(), "o", [CultureInfo]::InvariantCulture,
[System.Globalization.DateTimeStyles]::None)
}}
DateTime { [Func[[Object], [DateTime]]]{ [System.DateTime]($args[0].ToString()) } }
Instance { "dict" }
Real32 { "float" }
Real64 { [Func[[Object], [Double]]]{ [System.Double]::Parse($args[0].ToString()) } }

View file

@ -54,8 +54,9 @@ options:
provided but a comma separated string also work. Use a list where
possible as no escaping is required and it works with more complex types
list C(CimInstance[]).
- If the type of the DSC resource option is a C(DateTime), use a string in
the form of an ISO 8901 string.
- If the type of the DSC resource option is a C(DateTime), you should use
a string in the form of an ISO 8901 string to ensure the exact date is
used.
- Since Ansible 2.8, Ansible will now validate the input fields against the
DSC resource definition automatically. Older versions will silently
ignore invalid fields.