I've some trouble finding the right DateTimeFormatter for the user.
When converting a date to a string for example with
.ToString("D");
always the en-US culture is used in WinRT.
I found out that there are new globalization apis which should be used.
for example
var langs = Windows.System.UserProfile.GlobalizationPreferences.Languages;
var homeregion = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion;
Windows.Globalization.DateTimeFormatting.DateTimeFormatter dtf = new DateTimeFormatter(homeregion);
but the result of HomeGeographicRegion is not in the format with a new DateTimeformatter requires
I also tried this
var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(Windows.Globalization.DateTimeFormatting.YearFormat.Default,
Windows.Globalization.DateTimeFormatting.MonthFormat.Abbreviated,
Windows.Globalization.DateTimeFormatting.DayFormat.Default,
Windows.Globalization.DateTimeFormatting.DayOfWeekFormat.Default);
string result = formatter.Format(Date);
but that also only returns date string in en-Us format.
Can anyour tell me what is the correct way to get a DateTimeFormatter according to the users culture (which is also automatically used for resource localizations via uid)?