Created
May 18, 2018 16:02
-
-
Save hagatorn/7ea6e2e4bcbea45cf41ec07dc59b20a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[CmdletBinding()] | |
[ValidatePattern('^(((?<days>[0-9]+)\+)?((?<hours>[0-9]{1,2}):))?(?<mins>[0-9]{1,2})$')] | |
[string]$quserTimeString | |
) | |
$string = $quserTimeString | |
[int]$mins = if($string.Contains(':')){$string.split(":")[1]}else{$string} | |
[int]$index = $string.IndexOf('+') | |
[int]$hours = if($string.Contains(':')){$string.split(":")[0].Substring($index+1)} | |
[int]$days = if($string.Contains('+')){ $string.split("+")[0]} | |
[Timespan]::new($days, $hours, $mins, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment