-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
PowerShell 7.1 preview 3 doesn't use configured date/time format #12755
Comments
Is this behaviour new in the latest preview or has it always been this way? |
I would say it's new in preview 3. Too bad, I've just upgraded my last system, so I don't have any preview 2 system anymore. |
We'll need to confirm if there was a change at some point or if this is the original behaviour. Also, can you confirm if this is affected at all by using the |
We use |
In 7.0.1:
In 7.1 preview 3:
|
|
Looks like a regression indeed. @iSazonov do you know if there were any changes merged to this area of code since 7.1-p2? I can't recall any at the moment. Perhaps it's a regression or change in .NET Core? |
Here's what I get with preview 2 on the same system:
|
I can not confirm. After I changed these format strings in registry and restarted PowerShell I get right outputs. |
What? Where was changing the format strings in the registry mentioned here? 😕 |
To get things right I uninstalled preview 3 and installed preview 2 😜 |
This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes. |
I don't understand: there is an issue in preview 3, it has to be fixed! |
I can repo. We need reliable repo steps. |
You mean you can't repro? I don't have a clean system to test on (could set up a test VM, but would take a significant amount of time). I'll test with XCOPY-deployed SxS installations of preview 2 and preview 3. |
Here's the outcome, using these launch scripts:
Repro'ed on two different systems. |
What is output: $Host (Get-Culture).DateTimeFormat |
On preview 2:
On preview 3:
|
What is time you change the datetime format? The PowerShell versions use different .Net 5 Preview - 3 and 4. |
I'm not sure I understand your question. When did I change the datetime format? That must've been when I installed the systems in the first place, 'cos as a software engineer I prefer 1) the English UI, so I changed the display language to English (my computers came with French Windows) 2) the ISO8601 YYYY-MM-DD date format. So I've probably never run any version of PowerShell with the default en-US date/time formats. Where can I get the nightly builds from? What is the .NET Core API that's used by PowerShell Core to convert a date/time to string? I need this information if I want to open an issue on .NET 5.0. |
You can download night build from main page of the repository. PowerShell uses Datetime.ToLongTimeString() method. All formats you get above with (Get-Culture).DateTimeFormat. |
On that main page, I can see the status of the nightly builds in CI, but no download links. Am I missing something? I'll try creating a C# test program and run it with various previous versions of .NET 5. |
Press on the status icon and look artifacts under "Build for Windows". |
The code that handles this is here: PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CsvCommands.cs Lines 1045 to 1067 in b1e9980
With this code in mind, can you check what you get back for I'm reopening this as it doesn't look like we've gotten to the bottom of it yet. 🙂 |
It seems .Net has an option to opt out ICU. You could try and see a result. |
No, there is an option to switch back from ICU to Windows traditional API. |
See https://docs.microsoft.com/en-us/dotnet/core/run-time-config/globalization#nls
|
Will test... The change to use ICU was introduced in .NET 5 preview 4... |
Bingo! The .NET folks marked my issue as a duplicate of dotnet/runtime#37121, where @safern claims this was fixed for .NET 5 Preview 5--not what I see... Am I correct to assume that you will not want to use NLS in PowerShell? IMVHO this would be a potential cause for PowerShell behaving differently on Windows and on other platforms. |
That claim from my side was initially wrong as I thought dotnet/runtime#37121 was a dupe of dotnet/runtime#35638 which was fixed in Preview5. I expect to have a fix for dotnet/runtime#37121 this week and hopefully will be able to port it to Preview6 on time. |
PowerShell follows .Net (and OS) improvements. It would be amazing for users to discover that PowerShell works differently than other .Net and native OS applications. |
@iSazonov I'm not sure I know how to interpret your answer. Are you (on behalf of the PowerShell team) in favor of aligning PowerShell on Windows with all other Windows applications (in which case NLS is the norm), or of aligning PowerShell on Windows with PowerShell on other platforms (in which case ICU's behavior will rule)? |
For now, I might go for setting |
@sba923 Since NLS and ICU have differences it can be a problem - one .Net application can work differently on different OS-es. MSFT has started to migrate to ICU. It was added in latest Window versions and .Net 5.0 uses ICU by default. |
So you'll go for PS7.1 using ICU, and assuming this is backwards compatible e.g. abides by the user's settings, correct? |
@sba923 7.1 will be on .Net 5.0. If the .Net will use ICU by default PowerShell will do the same. |
Should be OK, provided this does not introduce severe breaking changes. |
Expectedly, the issue is still present in 7.1 preview 4... |
To give an update I have a PR out for the fix: dotnet/runtime#38372 |
Good! See my comment there about taking user changes into account on the fly. Does this need a code change on the PowerShell side of things? |
If PowerShell 7.0 version sees the time (culture) changes immediately, then we get a breaking change. |
How do you mean? That 7.1 should behave the same as 7.0? I don't know what 7.0's behavior is, but I would expect that it takes user changes into account dynamically. |
PS C:\src\t> ($PSVersionTable.PSVersion).ToString(),(Get-Culture).DateTimeFormat.ShortDatePattern PS C:\src\t> ($PSVersionTable.PSVersion).ToString(),(Get-Culture).DateTimeFormat.ShortDatePattern |
.Net fix was merged. We get it soon. (.Net 5.0 Preview8) |
What's the plan for testing? How difficult is it to make a private build of PS7.1 with that .NET fix in so that we can test for side effects / regressions ? |
@sba923 You could build .Net locally and test. But it is not worth the effort. We can wait about a month. |
Still waiting for .NET Preview 8 to be released... |
PowerShell 7.1.0-preview.7 ships with .NET Preview 8, which should address this issue. Let us know if it hasn't. |
I concur 😜
|
This should speak for itself:
Steps to reproduce
en-US
cultureHH:mm:ss
and date format toyyyy-MM-dd
via SettingsGet-Date | ConvertTo-Csv
Expected behavior
Time is formatted using 24-hr format, date using specified
yyyy-MM-dd
format.Actual behavior
Time is formatted in 12-hr am/pm format, date using
M/dd/yyyy
formatEnvironment data
The text was updated successfully, but these errors were encountered: