2

I searched for an answer to this question, but all I found is how to show 12-hour versus 24-hour time format rather than when to do that.

My question is similar to this one: How to determine if current culture/locale uses am/pm or 24-hour time? but I want to know if we have similar structure to CurrentCulture or CultureInfo in Rails.

I believe with use of locales it should be possible, but I do not know how to do it or if there is any database explicitly mentioning which languages use military format (24-hour) and which use AM/PM format.

Community
  • 1
  • 1
AliKH
  • 71
  • 1
  • 6
  • 1
    could the user just choose what they prefer when signing up/in settings? – dax Oct 02 '13 at 18:28
  • That would impose a manual configuration. What I was looking for is a more intelligent way to check the locale of the logged_in_user and show the proper form. So far, I could only make a list and check if the locale is in that list and manually show a different dropdown using "time_select" with ampm => true/false – AliKH Oct 02 '13 at 22:41
  • Here's a quick-and-dirty approximation: get new user's country (from IP). If it's US or UK, set 12-hour clock. Else set 24-hour clock. Oh and yes, expose this setting in the UI, so that user can change it. – Sergio Tulentsev Aug 15 '14 at 07:33

1 Answers1

0

According to this wikipedia article, in most English-speaking regions, particularly the United States, the Philippines and the United Kingdom and its former colonies, the 12-hour clock is the predominant form of stating the time. Here is the relevant excerpt from the article:

In most English-speaking regions, particularly the United States, the Philippines and the United Kingdom and its former colonies, the 12-hour clock is the predominant form of stating > the time with the 24-hour clock used in contexts where unambiguity and accurate timekeeping > are important, such as for public transport schedules. Nonetheless, usage is inconsistent: in the UK, train timetables will typically use 24-hour time, but road signs indicating time > restrictions (e.g. on bus lanes) typically use 12-hour time.

Therefore, I suggested by Sergio in the comment, you may want to use geolocation to determine the appropriate default for the user and then expose the setting in the user interface to let the user fine tune this setting.

David Segonds
  • 83,345
  • 10
  • 45
  • 66