Created
December 19, 2022 15:31
-
-
Save mcc85s/216fd2351d09d0f35dddff411b1c3b6d to your computer and use it in GitHub Desktop.
This file contains 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
# // ================================================================================================================ | |
# // | This script creates a time object similar to the [System.Diagnostics.Stopwatch] object, but is much simpler. | | |
# // ================================================================================================================ | |
# [Script area] | |
# Overload class definition | |
Class Time | |
{ | |
Hidden [Object] $Start | |
Time() | |
{ | |
$This.Start = [DateTime]::Now | |
} | |
[String] ToString() | |
{ | |
Return [Timespan]([DateTime]::Now-$This.Start) | |
} | |
} | |
# Instantiate object to variable $Time | |
$Time = [Time]::New() | |
# // Use the variable itself to get the time | |
$Time | |
# [Output area] | |
# PS:\> 00:00:52.7844982 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment