Logo Search packages:      
Sourcecode: pan version File versions  Download package

size_t EvolutionDateMaker::e_strftime_fix_am_pm ( char *  s,
size_t  max,
const char *  fmt,
const struct tm *  tm 
) const [private]

Function to do a last minute fixup of the AM/PM stuff if the locale and gettext haven't done it right. Most English speaking countries except the USA use the 24 hour clock (UK, Australia etc). However since they are English nobody bothers to write a language translation (gettext) file. So the locale turns off the AM/PM, but gettext does not turn on the 24 hour clock. Leaving a mess.

This routine checks if AM/PM are defined in the locale, if not it forces the use of the 24 hour clock.

The function itself is a front end on strftime and takes exactly the same arguments.

TODO: Actually remove the 'p' from the fixed up string so that there isn't a stray space.

Definition at line 140 of file e-util.cc.

  size_t ret;

  if (am_pm_are_defined_in_locale || (!strstr(fmt,"%p") && !strstr(fmt,"%P")))
    // either no AM/PM involved,
    // or it is involved and we can handle it
    ret = e_strftime (s, max, fmt, tm);
  else // no am/pm defined... change to a 24 hour clock
    char * ffmt = g_strdup (fmt);
    for (char * sp=ffmt; (sp=strstr(sp, "%l")); ++sp)
      sp[1]='H'; // maybe this should be 'k' but I've never seen a 24 clock actually use that format
    for (char * sp=ffmt; (sp=strstr(sp, "%I")); sp++)
    ret = e_strftime(s, max, ffmt, tm);
    g_free (ffmt);
  return ret;

Generated by  Doxygen 1.6.0   Back to index