Skip to content

Derive default formats for dates and times from user profile language #109

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

Open
VisualAlf opened this issue Feb 15, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@VisualAlf
Copy link
Contributor

... and not from app runtime language.

Running the new SampleApp I noticed the 'Dob' and the 'Active At' Columns have the US-Format (12Hour and MM/dd/yyyy).
Instead in Germany it should be 24HourClock and Dateformat dd.MM.yyyy

Image

I believe the reason why this happens with the SampleApp but not with my own Apps, is the entry 'Default Language' within Package.appxmanifest.
Which is set to 'en_US' in SampleApp, but to 'de-DE' within mine. So it seems, DateTimeFormatter selects the app runtime language.

Instead we should use the user profile language as defined in (win11) Settings > Time & Language > Region & language > Languages. Then the user will automatically see the date/time formats s/he is used to, and not the ones the developer of the app is used to use.

One way to achieve this is to change the default formats in TableViewTimeColumn and in TableViewDateColumn.

  • in TableViewTimeColumn.ctor
    from: ClockIdentifier = DateTimeFormatter.ShortTime.Clock;
    to: ClockIdentifier = GlobalizationPreferences.Clocks[0];

  • in TableViewDateColumn.ctor
    from: DateFormat = DateTimeFormatter.ShortDate.Patterns[0];
    to: DateFormat = new DateTimeFormatter("shortdate", GlobalizationPreferences.Languages).Patterns[0];

@VisualAlf VisualAlf added the enhancement New feature or request label Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant