Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ protected override void ProcessRecord()
{
TimeSpan uptime = TimeSpan.FromSeconds(Stopwatch.GetTimestamp() / Stopwatch.Frequency);

switch (ParameterSetName)
if (Since)
{
case TimespanParameterSet:
// return TimeSpan of time since the system started up
WriteObject(uptime);
break;
case SinceParameterSet:
// return Datetime when the system started up
WriteObject(DateTime.Now.Subtract(uptime));
break;
// Output the time of the last system boot.
WriteObject(DateTime.Now.Subtract(uptime));
Comment thread
logiclrd marked this conversation as resolved.
}
else
{
// Output the time elapsed since the last system boot.
WriteObject(uptime);
Comment thread
logiclrd marked this conversation as resolved.
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Describe "Get-Uptime" -Tags "CI" {
$upt = Get-Uptime -Since
$upt | Should -BeOfType DateTime
}
It "Get-Uptime -Since:`$false return TimeSpan" {
Comment thread
logiclrd marked this conversation as resolved.
$upt = Get-Uptime -Since:$false
$upt | Should -BeOfType TimeSpan
}
It "Get-Uptime throw if IsHighResolution == false" {
# Enable the test hook
[system.management.automation.internal.internaltesthooks]::SetTestHook('StopwatchIsNotHighResolution', $true)
Expand Down
Loading