locked
Wrong DateTimeFormatInfo properties in Current culture object RRS feed

  • Question

  • Hi!

    I'm running into a problem in my Windows Store App. Here is the explanation:

    I would like to retrieve the Short Time Pattern selected in the user regional settings to determine if I'm using the 12 hours format or the 24 hours format in my system settings.

    Normally, I would get the DateTimeFormatInfo object that I can find in CultureInfo.CurrentCulture.DateTimeFormat and read the ShortTimePattern property. 

    The problem is that the DateTimeFormatInfo has wrong values, well actually the values of the current culture.

    But if I choose English as language but French as format (in "Control Panel > Clock, Language, and Region > Language > Change date, time, or number formats" settings), the value of the ShortTimePattern property is not the same. However, the format of the system time has changed..

    I found that on MSDN: (http://msdn.microsoft.com/en-us/library/vstudio/system.globalization.datetimeformatinfo.aspx#instantiating_Current)

    • User preferences. Users of your application might choose to override some of the values associated with the current system culture through the regional and language options in Control Panel. For example, users might choose to display the date in a different format. If theCultureInfo.UseUserOverride property is set to true, the properties of the DateTimeFormatInfo object is also retrieved from the user settings. If the user settings are incompatible with the culture associated with the CultureInfo object (for example, if the selected calendar is not one of the calendars indicated by the OptionalCalendars property), the results of the methods and the values of the properties are undefined.

    But it seems like the DateTimeFormatInfo is not retrieved from the user settings, or maybe I'm doing something wrong?

    Thanks for help!

    Nicolas

    Wednesday, October 9, 2013 3:05 PM

Answers

  • Hi Nicolas,

    you can get only the system setting from a Windows Store app. The docs you mention note that UseUserOverride is not available for Windows Store apps.

    • Marked as answer by NRion Thursday, October 10, 2013 9:50 AM
    Wednesday, October 9, 2013 5:57 PM
    Moderator

All replies

  • Hi Nicolas,

    you can get only the system setting from a Windows Store app. The docs you mention note that UseUserOverride is not available for Windows Store apps.

    • Marked as answer by NRion Thursday, October 10, 2013 9:50 AM
    Wednesday, October 9, 2013 5:57 PM
    Moderator
  • Hi Rob!

    Thanks for your answer, I didn't see that... :(

    Do you know if that will be available in Windows 8.1 or not at all?

    I mark the question as answered.

    Nicolas


    • Edited by NRion Thursday, October 10, 2013 9:48 AM
    Thursday, October 10, 2013 9:44 AM
  • No changes here for Windows 8.1.

    --Rob

    Thursday, October 10, 2013 3:51 PM
    Moderator