Skip to content

Change to use pwsh to have consistent JSON conversion for DateTime - #11126

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:ymal
Nov 26, 2019
Merged

Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:ymal

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Nov 19, 2019 •

Copy link
Copy Markdown
Member

PR Summary

ConvertTo-Json has different behavior when it comes to DateTime type in Windows PowerShell and PowerShell Core

## pwsh
PS:6> $dateTime = [datetime]::UtcNow
PS:7> $dateTime = [datetime]::new($dateTime.Ticks - ($dateTime.Ticks % [timespan]::TicksPerSecond), $dateTime.Kind)
PS:8> @{ datetime = $dateTime } | ConvertTo-Json
{
  "datetime": "2019-11-19T22:32:50Z"
}
## powershell.exe
PS:11> $dateTime = [datetime]::UtcNow
PS:12> $dateTime = [datetime]::new($dateTime.Ticks - ($dateTime.Ticks % [timespan]::TicksPerSecond), $dateTime.Kind)
PS:13> @{ datetime = $dateTime } | ConvertTo-Json
{
    "datetime":  "\/Date(1574202819000)\/"
}

tools/releaseBuild/setReleaseTag.ps1 uses the DateTime as a property for the JSON file. Change the ymal file to use pwsh instead of powershell to get consistent behavior.

PR Context

PR Checklist

@daxian-dbw

Copy link
Copy Markdown
Member Author

This is a simple change that make the build use pwsh instead of powershell.exe. I will just merge it.

@ghost

Copy link
Copy Markdown

🎉v7.1.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants