-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Make Start-Sleep accept fractional seconds #8477
Description
Summary of the new feature/enhancement
While Start-Sleep -MilliSeconds offers fine-grained control over the sleep duration, it would be convenient not to have two switch parameters just to be able to effectively specify fractional seconds.
E.g., instead of:
Start-Sleep -MilliSeconds 1400it would be nice to be able to write:
Start-Sleep 1.4 # wishful thinking; translate into 1,400 msecs.This is in line with the sleep utility on macOS and Linux, which accepts fractional values (e.g., sleep 1.4)
Currently, fractional values are quietly converted to [int] values, which means that rounding is applied, which is not only obscure behavior, but behavior that existing code is unlikely to rely upon.
As an aside: Start-Sleep is misnamed and should be called Invoke-Sleep - see #3990.
Proposed technical implementation details (optional)
Change the data type of the -Seconds parameter from [int] to [double] and simply cast the internal conversion to milliseconds to (int).