New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special case DateTime/TimeSpan in Format-Custom #18142
Comments
You can see a more real world case with |
+1 to that, |
How about a more general parameter like # get single line date
dir | select -first 1 | format-custom # get way too much output
dir | select -first 1 | format-custom -ExpandType:System.Datetime, SomeFutureNoisyType |
DateTime already has an entry for custom formatting, but it is not applied when datetime is a member. private static IEnumerable<FormatViewDefinition> ViewsOf_System_DateTime()
{
yield return new FormatViewDefinition("DateTime",
CustomControl.Create()
.StartEntry()
.AddPropertyExpressionBinding(@"DateTime")
.EndEntry()
.EndControl());
} [DateTime]::Now | format-custom
den 14 oktober 2022 09:51:00 |
…as scalar. See issue PowerShell#18142
@JamesWTruher Can you provide an opinion here? |
There are some types in dotnet which have elements of recursion and datetime is one of those. Remember that the a new formatting frame is not added once you start rendering, so if you have And, as you've noticed, In the non-custom formatting cases, we simply call the This is all for the relatively low use case of |
Produce one-line output in Format-Custom for DateTime by default
Dates and times get really spammy in
Format-Custom
This simple object with a datetime
produces 148 lines of output!
I suggest that we should special-case DateTime in the custom formatted to only print the string same string as we get when we limit the depth:
So that
would output
Maybe use
-Force
to get the full recursive version?Proposed technical implementation details (optional)
No response
The text was updated successfully, but these errors were encountered: