-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add -FromUnixTime to Get-Date to allow Unix time input
#12179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -FromUnixTime to Get-Date to allow Unix time input
#12179
Conversation
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Date.Tests.ps1
Outdated
Show resolved
Hide resolved
|
Upon specifying UTC in the tests, I noticed a small inconsistency. When specifying the DateTime with ticks, or with unix time, the This was causing issues when combined with the To get around this, we can set the to |
src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetDateCommand.cs
Outdated
Show resolved
Hide resolved
This reverts commit c76eebe.
|
@jackdcasey Please create new issue in PowerShell-Docs repo for the new parameter and add reference in the PR description. Thanks! |
|
Opened issue in MicrosoftDocs/PowerShell-Docs: MicrosoftDocs/PowerShell-Docs#5727 |
-FromUnixTime to Get-Date to allow Unix time input
|
@jackdcasey Thanks for your contribution! |
|
@iSazonov Thank you for all the help! |
|
🎉 Handy links: |
|
Negative UnixTime is not supported? |
|
@aetos382 No. If you have a feature request please open new issue. |
PR Summary
My proposal, is to add a
-FromUnixTimeswitch to Get-Date.This allows the input of a Unix timestamp into
Get-Date. This is currently impossible, as the default unit for a numeric input is ticks.Adding this switch would allow the user to specify if the input is Unix time, while also keeping full previous compatibility with ticks.
Here is an example output with, and without the switch:
PR Context
Closes #11719
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.