determine if “24-hour clock” setting is set

后端 未结 4 1627
野性不改
野性不改 2020-12-11 07:40

What\'s the best way to determine if the user has set the \"24-hour clock\" setting to true in Settings-Date+Time on the Windows Phone ?

Can I get this information t

相关标签:
4条回答
  • 2020-12-11 08:22

    The system clock type can be retrieved using:

    string clockType = Windows.System.UserProfile.GlobalizationPreferences.Clocks.FirstOrDefault();
    

    This will return the string 24HourClock if the 24 hour setting is on in the device settings or 12HourClock if the setting is off.

    0 讨论(0)
  • 2020-12-11 08:24

    On the back of Dennis' answer, you should be able to determine 24-hour time using String.Contains:

    bool is24HourTime = DateTimeFormatInfo.CurrentInfo.ShortTimePattern.Contains("H");
    
    0 讨论(0)
  • 2020-12-11 08:24

    The DateTimeFormatInfo.CurrentInfo.ShortTimePattern way of getting the hour is tied to the culture, and not to the option showing whether 24-hour time is enabled or not. So you will get h:mm tt for English (United States) and HH:mm for German (Germany).

    At this moment, you cannot get this system setting.

    0 讨论(0)
  • 2020-12-11 08:27

    For japanese developers, please note.

    DateTimeFormatInfo.CurrentInfo.ShortTimePattern in the culture ja-JP will return the same string H:mm, regardless of if the phone setting for 24-Hour time is enabled or not.

    0 讨论(0)
提交回复
热议问题