Changing the date / time format reflect to the CurrentCulture all the time
See original GitHub issueBackground and Motivation
Changing the culture date/time format reflect to the default culture, there’s no way in the current APIs to allow the user doesn’t rely on the system settings
Proposed API
+ private readonly bool _useUserOverride;
+
private RequestCulture _defaultRequestCulture =
new RequestCulture(CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture);
- public RequestLocalizationOptions()
+ public RequestLocalizationOptions() : this(useUserOverride: true)
{
- RequestCultureProviders = new List<IRequestCultureProvider>
- {
- new QueryStringRequestCultureProvider { Options = this },
- new CookieRequestCultureProvider { Options = this },
- new AcceptLanguageHeaderRequestCultureProvider { Options = this }
- };
}
+ public RequestLocalizationOptions(bool useUserOverride)
+{
+ _useUserOverride = useUserOverride;
+ RequestCultureProviders = new List<IRequestCultureProvider>
+ {
+ new QueryStringRequestCultureProvider { Options = this },
+ new CookieRequestCultureProvider { Options = this },
+ new AcceptLanguageHeaderRequestCultureProvider { Options = this }
+ };
Usage Examples
var options = new RequestLocalizationOptions(useUserOverride: true);
app.UseRequestLocalization(options);
Alternative Designs
Risks
Issue Analytics
- State:
- Created a year ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
c# - How to change "CurrentThread.CurrentCulture. ...
1. Or you can use DateTime. · 1. You'd probably have to change your current culture, not just your date time format settings,...
Read more >CultureInfo.CurrentCulture Property (System.Globalization)
The CultureInfo object that this property returns is read-only. That means you can't mutate the existing object, for example, by changing the DateTimeFormat...
Read more >Standard date and time format strings
Learn how to use a standard date and time format string to define the text representation of a date and time value in...
Read more >c# Datetime Examples - Franco Morales
Current culture is ES – the default format for it, it's : “dd/MM/yyyy”. When we try to convert “24/12/2020 23:50” to this culture,...
Read more >CurrentCulture - 2000 Things You Should Know About WPF
Current culture impacts the display of the following: Numeric data; Date/time values; Currency values. All of these values are typically ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You need to update
PublicAPI.Unshipped.txt
instead ofPublicAPI.Shipped.txt
. We generally only update thePublicAPI.Shipped.txt
files once a year after we’ve shipped new APIs as part of a major release. You can read more about these files in our API Baselines doc.As suggested in that doc, you can apply the RS0016 code fix in VS to update
PublicAPI.Unshipped.txt
automatically. If it doesn’t work out for you, just try making the actual code change and we can updatePublicAPI.Unshipped.txt
for you.@hishamco It wasn’t just me that decided on
CultureInfoUseUserOverride
. Members of @dotnet/aspnet-api-review had a vote and approved it. We discussed yourUseSystemCultureSettings
andUseUserOverrideCulture
naming suggestions, but we still preferCultureInfoUseUserOverride
. If you want us to merge your PR, it must match the approved API.