Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

determine if "24-hour clock" setting is set

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 through the CurrentCulture (CultureInfo) ? I had no luck in finding it.

like image 347
invalidusername Avatar asked Jan 19 '23 19:01

invalidusername


2 Answers

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.

like image 111
user994597 Avatar answered Jan 27 '23 23:01

user994597


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");
like image 39
Richard Szalay Avatar answered Jan 27 '23 22:01

Richard Szalay