Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ Describe 'ConvertTo-Json' -tags "CI" {

It 'Should not serialize ETS properties added to DateTime' {
$date = "2021-06-24T15:54:06.796999-07:00"
$d = [DateTime]::Parse($date)
$d = [DateTimeOffset]::Parse($date, [System.Globalization.CultureInfo]::InvariantCulture, [System.Globalization.DateTimeStyles]::RoundtripKind).UtcDateTime

# need to use wildcard here due to some systems may be configured with different culture setting showing time in different format
$d | ConvertTo-Json -Compress | Should -BeLike '"2021-06-24T*'
$json = $d | ConvertTo-Json -Compress
$json | Should -Match '^"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z"$'
[DateTime]::Parse($json.Trim('"'), [System.Globalization.CultureInfo]::InvariantCulture, [System.Globalization.DateTimeStyles]::RoundtripKind) | Should -Be $d
$d | ConvertTo-Json | ConvertFrom-Json | Should -Be $d
}

Expand Down