Skip to content
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

Always use DateTime.ToString() instead of implicit casting to use current culture instead of invariant one #81

Open
wants to merge 1 commit into
base: Legacy
Choose a base branch
from

Conversation

Indigo744
Copy link

When converting a DateTime to a string, if ToString() is not explicitly called then Powershell use the invariant locale (en-us) instead of the current locale.

For instance on my machine (with French culture fr-fr):

> "$(Get-Date)"
02/09/2024 22:29:36 # mm/dd/yyyy

> "$((Get-Date).ToString())"
09/02/2024 22:31:40 # dd/mm/yyyy

More information here: https://jhoneill.github.io/powershell/2022/03/06/DateFormats.html

So in order to respect the current locale, ToString() must be call.

@PrzemyslawKlys
Copy link
Member

Thank you. As I plan for V3, this may come useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants