Closed rickardliljeberg closed 8 years ago
LocalizedApplication.Current.SetPrincipalAppLanguageForRequestHandlers = null;
will prevent i18n from changing Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture.
Or you can hookup your own delegate to customize this.
In my case I made all code call a custom Now function that solved it easiest for me
like so
public static DateTime GregorianUTCNow()
{
DateTime returnVar;
try
{
CultureInfo originalCulureInfoUI = CultureInfo.CurrentUICulture;
CultureInfo originalCulureInfo = CultureInfo.CurrentCulture;
try
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
returnVar = DateTime.UtcNow;
}
finally
{
Thread.CurrentThread.CurrentUICulture = originalCulureInfo;
}
}
finally
{
}
return returnVar;
}
Actually, scratch that.
In the end I had to go with your approach as otherwise I could not get it to recieve date fields´.
So I have a project that required Arabic.
But when i switch to arabic it seems more than i bargained for is switches as I now get DateTimes with the year 1437 which is the Arabic calendars year.
If you look at this screenshot I tried to work around it https://db.tt/YVPReCBJ
I set us culture, send in a date in year 2015. But still, the datetime created is for year 1437.... any ideas?
I do not want arabic calendar as all as client told me that most arabic countries actually run by gregorian calendar.