Bumped the version number to 0.12.99.0.
2001-09-22 Christopher James Lahey <clahey@ximian.com> * configure.in: Bumped the version number to 0.12.99.0. From a patch by Damian Ivereigh <damian@cisco.com>: * gal/util/e-util.c, gal/util/e-util.h (e_strftime_fix_am_pm): New function, takes the same arguments as strftime, but does some fixup if the given string is in 12 hour mode but the locale doesn't have AM/PM descriptors. From gal/e-table/ChangeLog: 2001-09-22 Christopher James Lahey <clahey@ximian.com> From a patch by Damian Ivereigh <damian@cisco.com>: * e-cell-date.c: Made this use e_strftime_fix_am_pm instead of strftime. svn path=/trunk/; revision=13081
This commit is contained in:
committed by
Chris Lahey
parent
8d22486006
commit
12ecaf7cef
@ -31,6 +31,7 @@
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "e-util.h"
|
||||
#if 0
|
||||
@ -1115,3 +1116,65 @@ e_sort (void *base,
|
||||
g_free(base_copy);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct tm *tm)
|
||||
{
|
||||
char buf[10];
|
||||
char *sp;
|
||||
char *ffmt;
|
||||
size_t ret;
|
||||
|
||||
if (strstr(fmt, "%p")==NULL && strstr(fmt, "%P")==NULL) {
|
||||
/* No AM/PM involved - can use the fmt string directly */
|
||||
ret=strftime(s, max, fmt, tm);
|
||||
} else {
|
||||
/* Get the AM/PM symbol from the locale */
|
||||
strftime (buf, 10, "%p", tm);
|
||||
|
||||
if (buf[0]) {
|
||||
/**
|
||||
* AM/PM have been defined in the locale
|
||||
* so we can use the fmt string directly
|
||||
**/
|
||||
ret=strftime(s, max, fmt, tm);
|
||||
} else {
|
||||
/**
|
||||
* No AM/PM defined by locale
|
||||
* must change to 24 hour clock
|
||||
**/
|
||||
ffmt=g_strdup(fmt);
|
||||
for (sp=ffmt; (sp=strstr(sp, "%l")); sp++) {
|
||||
/**
|
||||
* Maybe this should be 'k', but I have never
|
||||
* seen a 24 clock actually use that format
|
||||
**/
|
||||
sp[1]='H';
|
||||
}
|
||||
for (sp=ffmt; (sp=strstr(sp, "%I")); sp++) {
|
||||
sp[1]='H';
|
||||
}
|
||||
ret=strftime(s, max, ffmt, tm);
|
||||
g_free(ffmt);
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
@ -103,6 +103,10 @@ void e_bsearch (cons
|
||||
gpointer closure,
|
||||
size_t *start,
|
||||
size_t *end);
|
||||
size_t e_strftime_fix_am_pm (char *s,
|
||||
size_t max,
|
||||
const char *fmt,
|
||||
const struct tm *tm);
|
||||
void e_marshal_INT__INT_INT_POINTER (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
|
||||
@ -39,7 +39,7 @@ ecd_get_text(ECellText *cell, ETableModel *model, int col, int row)
|
||||
localtime_r (&nowdate, &now);
|
||||
|
||||
if (nowdate - date < 60 * 60 * 8 && nowdate > date) {
|
||||
strftime (buf, 26, _("%l:%M %p"), &then);
|
||||
e_strftime_fix_am_pm (buf, 26, _("%l:%M %p"), &then);
|
||||
done = TRUE;
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ ecd_get_text(ECellText *cell, ETableModel *model, int col, int row)
|
||||
if (then.tm_mday == now.tm_mday &&
|
||||
then.tm_mon == now.tm_mon &&
|
||||
then.tm_year == now.tm_year) {
|
||||
strftime (buf, 26, _("Today %l:%M %p"), &then);
|
||||
e_strftime_fix_am_pm (buf, 26, _("Today %l:%M %p"), &then);
|
||||
done = TRUE;
|
||||
}
|
||||
}
|
||||
@ -59,10 +59,10 @@ ecd_get_text(ECellText *cell, ETableModel *model, int col, int row)
|
||||
then.tm_year == yesterday.tm_year) {
|
||||
#if 0
|
||||
if (nowdate - date < 60 * 60 * 12) {
|
||||
strftime (buf, 26, _("Late Yesterday %l:%M %p"), &then);
|
||||
e_strftime_fix_am_pm (buf, 26, _("Late Yesterday %l:%M %p"), &then);
|
||||
} else {
|
||||
#endif
|
||||
strftime (buf, 26, _("Yesterday %l:%M %p"), &then);
|
||||
e_strftime_fix_am_pm (buf, 26, _("Yesterday %l:%M %p"), &then);
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
@ -77,7 +77,7 @@ ecd_get_text(ECellText *cell, ETableModel *model, int col, int row)
|
||||
if (then.tm_mday == yesterday.tm_mday &&
|
||||
then.tm_mon == yesterday.tm_mon &&
|
||||
then.tm_year == yesterday.tm_year) {
|
||||
strftime (buf, 26, _("%a %l:%M %p"), &then);
|
||||
e_strftime_fix_am_pm (buf, 26, _("%a %l:%M %p"), &then);
|
||||
done = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -85,9 +85,9 @@ ecd_get_text(ECellText *cell, ETableModel *model, int col, int row)
|
||||
}
|
||||
if (!done) {
|
||||
if (then.tm_year == now.tm_year) {
|
||||
strftime (buf, 26, _("%b %d %l:%M %p"), &then);
|
||||
e_strftime_fix_am_pm (buf, 26, _("%b %d %l:%M %p"), &then);
|
||||
} else {
|
||||
strftime (buf, 26, _("%b %d %Y"), &then);
|
||||
e_strftime_fix_am_pm (buf, 26, _("%b %d %Y"), &then);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
||||
Reference in New Issue
Block a user