-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
Summary of the new feature/enhancement
TimeSpans have all arithmetic operators defined on them (addition, subtraction, division, multiplication, equality, greater/less than). However, Measure-Object only works on numbers. If you pipe a TimeSpan to it, it will error with
measure-object : Input object "00:00:00" is not numeric.
It would be very useful if Measure-Object could work on TimeSpan objects too.
Example use case: Measure the time spent in meetings today and their average duration:
Get-GSCalendarEvent -TimeMin (Get-Date).Date -TimeMax (Get-Date).Date.AddDays(1) -SingleEvents |
ForEach-Object { $_.End.DateTime - $_.Start.DateTime } |
Measure-Object -AllStats
Count : 3
Average : 1:00:00
Sum : 3:00:00
Maximum : 2:00:00
Minimum : 0:30:00
StandardDeviation : 0:30:00
Property :Currently, this is more cumbersome:
Get-GSCalendarEvent -TimeMin (Get-Date).Date -TimeMax (Get-Date).Date.AddDays(1) -SingleEvents |
ForEach-Object { $_.End.DateTime - $_.Start.DateTime } |
ForEach-Object { $s = New-TimeSpan } { $s += $_ } { $s }And this only gets you the sum. All the other stats require way more code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module