Skip to content

Instantly share code, notes, and snippets.

@mcc85s
Created December 19, 2022 15:31
Show Gist options
  • Save mcc85s/216fd2351d09d0f35dddff411b1c3b6d to your computer and use it in GitHub Desktop.
Save mcc85s/216fd2351d09d0f35dddff411b1c3b6d to your computer and use it in GitHub Desktop.
# // ================================================================================================================
# // | 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