ConvertFrom-Json: Add -DateKind parameter - #20925
Conversation
Documents the -DateKind parameter that is part of the PR PowerShell/PowerShell#20925.
dc666e5 to
d630c18
Compare
Adds the -DateKind parameter to the ConvertFrom-Json that allows the caller to control how DateTime strings are converted into an object. The default behaviour is to create a DateTime value with the Kind being Unspecified if no TZ is set, Utc if the TZ Z is set, Local (after conversion) if an explicit TZ is set. This adds a Utc, Local to explicitly set the Kind as desired as well as a Offset and String value to create a DateTimeOffset or keep as a string.
|
Michael Klement (@mklement0) Could please review and confirm this work as you expect? |
| /// if the <paramref name="returnHashtable"/> parameter is true.</returns> | ||
| [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "Preferring Json over JSON")] | ||
| public static object ConvertFromJson(string input, bool returnHashtable, int? maxDepth, out ErrorRecord error) | ||
| => ConvertFromJson(input, returnHashtable, maxDepth, jsonDateKind: JsonDateKind.Local, out error); |
There was a problem hiding this comment.
Shouldn't this be JsonDateKind.Default?
There was a problem hiding this comment.
Yes it should be, sorry was playing around with comparing the defaults and never fixed this up when finalizing on the values.
Thanks for picking it up.
|
Thanks, Ilya (@iSazonov) - I have one small question (see above), but otherwise it looks great. Thank you for tackling this, Jordan Borean (@jborean93). |
…Cmdlet/JsonObject.cs
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
Documents the -DateKind parameter that is part of the PR PowerShell/PowerShell#20925.
Documents the -DateKind parameter that is part of the PR PowerShell/PowerShell#20925.
Steve Lee (SteveL-MSFT)
left a comment
There was a problem hiding this comment.
LGTM, great addition
|
📣 Hey Jordan Borean (@jborean93), how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
|
Jordan Borean (@jborean93) Thanks for your contribution! |
|
Thanks for the review everyone! |
Documents the -DateKind parameter that is part of the PR PowerShell/PowerShell#20925.
Documents the -DateKind parameter that is part of the PR PowerShell/PowerShell#20925.
Documents the -DateKind parameter that is part of the PR PowerShell/PowerShell#20925.
* ConvertFrom-Json: Add -DateKind parameter Documents the -DateKind parameter that is part of the PR PowerShell/PowerShell#20925. * Fix formatting, style, and wording --------- Co-authored-by: Sean Wheeler <[email protected]>
Adds the -DateKind parameter to the ConvertFrom-Json that allows the caller to control how DateTime strings are converted into an object. The default behaviour is to create a DateTime value with the Kind being Unspecified if no TZ is set, Utc if the TZ Z is set, Local (after conversion) if an explicit TZ is set. This adds a Utc, Local to explicitly set the Kind as desired as well as a Offset and String value to create a DateTimeOffset or keep as a string.
Adds the -DateKind parameter to the ConvertFrom-Json that allows the caller to control how DateTime strings are converted into an object. The default behaviour is to create a DateTime value with the Kind being Unspecified if no TZ is set, Utc if the TZ Z is set, Local (after conversion) if an explicit TZ is set. This adds a Utc, Local to explicitly set the Kind as desired as well as a Offset and String value to create a DateTimeOffset or keep as a string.
PR Summary
Adds the -DateKind parameter to the ConvertFrom-Json that allows the caller to control how DateTime strings are converted into an object. The default behaviour is to create a DateTime value with the Kind being Unspecified if no TZ is set, Utc if the TZ Z is set, Local (after conversion) if an explicit TZ is set. This adds a Utc, Local to explicitly set the Kind as desired as well as a Offset and String value to create a DateTimeOffset or keep as a string.
PR Context
Provides the user the ability to create a
DateTimeOffsetvalue so that the underlying time zone information is preserved. Also gives the user the ability to keep it as a string or a specificDateTimewith theLocalorUtckind.Fixes: #13598
Docs PR for this change: MicrosoftDocs/PowerShell-Docs#10737
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).