From 40577cb61ffdb4b94c8d5251bac7e07872fefc22 Mon Sep 17 00:00:00 2001 From: "James Truher [MSFT]" Date: Fri, 22 Sep 2017 11:25:48 -0700 Subject: [PATCH] Add the timezone offset correctly (#4867) It must be padded to 3 digits and prepended with either '-' or '+' An incorrectly formatted string will not be able to be converted back to a datetime --- test/powershell/engine/Cdxml/Cdxml.Tests.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/powershell/engine/Cdxml/Cdxml.Tests.ps1 b/test/powershell/engine/Cdxml/Cdxml.Tests.ps1 index d14c51b0b6..247125f2d0 100644 --- a/test/powershell/engine/Cdxml/Cdxml.Tests.ps1 +++ b/test/powershell/engine/Cdxml/Cdxml.Tests.ps1 @@ -59,7 +59,10 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { $currentTimeZone = [System.TimeZoneInfo]::Local # this date is simply the same one used in the test mof - $UTCOffset = ($currentTimeZone.GetUtcOffset([datetime]::new(2008, 01, 01, 0, 0, 0))).TotalMinutes.ToString() + # the minutes must be padded to 3 digits proceeded by a '+' or '-' + # when east of UTC 0 we must add a '+' + $offsetMinutes = ($currentTimeZone.GetUtcOffset([datetime]::new(2008, 01, 01, 0, 0, 0))).TotalMinutes + $UTCOffset = "{0:+000;-000}" -f $offsetMinutes $testMof = $testMof.Replace("", $UTCOffset) Set-Content -Path $testDrive\testmof.mof -Value $testMof $result = MofComp.exe $testDrive\testmof.mof