Title: ConvertFrom-JSON incorrectly deserializes dates to DateTime · Issue #13592 · PowerShell/PowerShell · GitHub
Open Graph Title: ConvertFrom-JSON incorrectly deserializes dates to DateTime · Issue #13592 · PowerShell/PowerShell
X Title: ConvertFrom-JSON incorrectly deserializes dates to DateTime · Issue #13592 · PowerShell/PowerShell
Description: When ConvertFrom-JSON guesses something in the input data can be converted to a DateTime, it (silently) does so. But the conversion doesn't correctly interprets some strings. Steps to reproduce I'm running this on a system that's on UTC+...
Open Graph Description: When ConvertFrom-JSON guesses something in the input data can be converted to a DateTime, it (silently) does so. But the conversion doesn't correctly interprets some strings. Steps to reproduce I'm...
X Description: When ConvertFrom-JSON guesses something in the input data can be converted to a DateTime, it (silently) does so. But the conversion doesn't correctly interprets some strings. Steps to reproduce...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/13592
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ConvertFrom-JSON incorrectly deserializes dates to DateTime","articleBody":"When `ConvertFrom-JSON` guesses something in the input data can be converted to a `DateTime`, it (silently) does so.\r\n\r\nBut the conversion doesn't correctly interprets some strings.\r\n\r\n\r\n## Steps to reproduce\r\n\r\nI'm running this on a system that's on UTC+2 (CEST).\r\n\r\n```\r\nWrite-Host(\"PowerShell version: \" + $PSVersionTable.PSVersion.ToString())\r\n$date = \"2020-09-07T09:44:13.769Z\"\r\nWrite-Host (\"Original string: \" + $date)\r\nWrite-Host(\"Cast to Datetime: \" + [datetime] $date)\r\n$json = ('[{\"start\":\"' + $date + '\"}]') \r\nWrite-Host(\"JSON data: \" + $json)\r\n$data = $json | ConvertFrom-Json\r\nWrite-Host($data[0].start.GetType().Name + \" resulting from ConvertFrom-JSON: \" + $data[0].start)\r\n```\r\n\r\n## Expected behavior\r\n\r\n```\r\nPowerShell version: 7.0.3\r\nOriginal string: 2020-09-07T09:44:13.769Z\r\nCast to Datetime: 09/07/2020 11:44:13\r\nJSON data: [{\"start\":\"2020-09-07T09:44:13.769Z\"}]\r\nDateTime resulting from ConvertFrom-JSON: 09/07/2020 11:44:13\r\n```\r\n\r\n## Actual behavior\r\n\r\n```\r\nPowerShell version: 7.0.3\r\nOriginal string: 2020-09-07T09:44:13.769Z\r\nCast to Datetime: 09/07/2020 11:44:13\r\nJSON data: [{\"start\":\"2020-09-07T09:44:13.769Z\"}]\r\nDateTime resulting from ConvertFrom-JSON: 09/07/2020 09:44:13\r\n```\r\n\r\n## Environment data\r\n\r\n```\r\nName Value\r\n---- -----\r\nPSVersion 7.0.3\r\nPSEdition Core\r\nGitCommitId 7.0.3\r\nOS Microsoft Windows 10.0.17763\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\nThe same issue is still present in 7.1.0-preview.6.\r\n","author":{"url":"https://github.com/sba923","@type":"Person","name":"sba923"},"datePublished":"2020-09-07T11:12:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":32},"url":"https://github.com/13592/PowerShell/issues/13592"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:65545290-ee9e-9d52-31df-76b5ed891c62 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E830:3CB45B:1B3357:254459:6A551E2F |
| html-safe-nonce | 91b0cc7339bc3bd05a2b25c7df92db0cb62fbdab98fe69e8a6671383fd11b74f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODMwOjNDQjQ1QjoxQjMzNTc6MjU0NDU5OjZBNTUxRTJGIiwidmlzaXRvcl9pZCI6IjMxNzg2MDU5Mzc3ODAxMzc1MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 92dc0ea24caca972790501ad17c9dc76a40174bbda06fedda491034402702aa5 |
| hovercard-subject-tag | issue:694992675 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/13592/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e8e634e9ca6efa67d9c416c7261ca3591c81f2b573f4479bcd6a50384cd93164/PowerShell/PowerShell/issues/13592 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e8e634e9ca6efa67d9c416c7261ca3591c81f2b573f4479bcd6a50384cd93164/PowerShell/PowerShell/issues/13592 |
| og:image:alt | When ConvertFrom-JSON guesses something in the input data can be converted to a DateTime, it (silently) does so. But the conversion doesn't correctly interprets some strings. Steps to reproduce I'm... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sba923 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 682d273eacb2ac51680c6eb9c0b270f029f7ce74c32090f319083c34497e28a5 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b6d37c6470adadff4194742daaab9a817cc4980 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width