This was recently discussed in #ubuntu-desktop, and the result was that the most robust solution is to ask
nl_langinfo (T_FMT) == '%T' -> 24 hour == '%r' -> AM/PM
T_FMT is what strftime(%X) uses as well.
http://sourceware.org/git/?p=glibc.git;a=blob;f=time/strftime_l.c;h=08c2aeb32be6421cb8075dfae3579da4ee02644a;hb=HEAD#l1177
This was recently discussed in #ubuntu-desktop, and the result was that the most robust solution is to ask
nl_langinfo (T_FMT)
== '%T' -> 24 hour
== '%r' -> AM/PM
T_FMT is what strftime(%X) uses as well.
http:// sourceware. org/git/ ?p=glibc. git;a=blob; f=time/ strftime_ l.c;h=08c2aeb32 be6421cb8075dfa e3579da4ee02644 a;hb=HEAD# l1177