Add %Ex extension to determine "%e %b" or "%b %e" order
Separate alternative for O and E cases
This commit is contained in:
parent
99833e1e47
commit
f72436c9ac
@ -75,10 +75,12 @@ _fmt(format, t, pt, ptlim)
|
||||
char *pt;
|
||||
const char *const ptlim;
|
||||
{
|
||||
int alternative;
|
||||
int Ealternative, Oalternative;
|
||||
|
||||
for ( ; *format; ++format) {
|
||||
if (*format == '%') {
|
||||
alternative = 0;
|
||||
Ealternative = 0;
|
||||
Oalternative = 0;
|
||||
label:
|
||||
switch (*++format) {
|
||||
case '\0':
|
||||
@ -96,7 +98,7 @@ label:
|
||||
continue;
|
||||
case 'B':
|
||||
pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ?
|
||||
"?" : (alternative ? Locale->alt_month :
|
||||
"?" : (Oalternative ? Locale->alt_month :
|
||||
Locale->month)[t->tm_mon],
|
||||
pt, ptlim);
|
||||
continue;
|
||||
@ -127,6 +129,8 @@ label:
|
||||
pt = _conv(t->tm_mday, "%02d", pt, ptlim);
|
||||
continue;
|
||||
case 'E':
|
||||
Ealternative++;
|
||||
goto label;
|
||||
case 'O':
|
||||
/*
|
||||
** POSIX locale extensions, a la
|
||||
@ -139,7 +143,7 @@ label:
|
||||
** representations.
|
||||
** (ado, 5/24/93)
|
||||
*/
|
||||
alternative = 1;
|
||||
Oalternative++;
|
||||
goto label;
|
||||
case 'e':
|
||||
pt = _conv(t->tm_mday, "%2d", pt, ptlim);
|
||||
@ -357,7 +361,7 @@ label:
|
||||
pt = _fmt(Locale->X_fmt, t, pt, ptlim);
|
||||
continue;
|
||||
case 'x':
|
||||
pt = _fmt(Locale->x_fmt, t, pt, ptlim);
|
||||
pt = _fmt(Ealternative ? Locale->Ex_fmt : Locale->x_fmt, t, pt, ptlim);
|
||||
continue;
|
||||
case 'y':
|
||||
pt = _conv((t->tm_year + TM_YEAR_BASE) % 100,
|
||||
|
@ -46,6 +46,8 @@ int _time_using_locale;
|
||||
#define LCTIME_SIZE_FULL (sizeof(struct lc_time_T) / sizeof(char *))
|
||||
#define LCTIME_SIZE_1 \
|
||||
(offsetof(struct lc_time_T, alt_month[0]) / sizeof(char *))
|
||||
#define LCTIME_SIZE_2 \
|
||||
(offsetof(struct lc_time_T, Ex_fmt) / sizeof(char *))
|
||||
|
||||
const struct lc_time_T _C_time_locale = {
|
||||
{
|
||||
@ -80,7 +82,7 @@ const struct lc_time_T _C_time_locale = {
|
||||
** "%a %b %d %H:%M:%S %Y"
|
||||
** is used by Solaris 2.3.
|
||||
*/
|
||||
"%a %b %e %X %Y",
|
||||
"%a %Ex %X %Y",
|
||||
|
||||
/* am */
|
||||
"AM",
|
||||
@ -89,12 +91,17 @@ const struct lc_time_T _C_time_locale = {
|
||||
"PM",
|
||||
|
||||
/* date_fmt */
|
||||
"%a %b %e %X %Z %Y",
|
||||
"%a %Ex %X %Z %Y",
|
||||
|
||||
{
|
||||
"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"
|
||||
}
|
||||
},
|
||||
|
||||
/* Ex_fmt
|
||||
** To determine months / day order
|
||||
*/
|
||||
"%b %e"
|
||||
};
|
||||
|
||||
|
||||
@ -173,6 +180,8 @@ __time_load_locale(const char *name)
|
||||
num_lines = split_lines(p, plim);
|
||||
if (num_lines >= LCTIME_SIZE_FULL)
|
||||
num_lines = LCTIME_SIZE_FULL;
|
||||
else if (num_lines >= LCTIME_SIZE_2)
|
||||
num_lines = LCTIME_SIZE_2;
|
||||
else if (num_lines >= LCTIME_SIZE_1)
|
||||
num_lines = LCTIME_SIZE_1;
|
||||
else
|
||||
|
@ -42,6 +42,7 @@ struct lc_time_T {
|
||||
const char * pm;
|
||||
const char * date_fmt;
|
||||
const char * alt_month[12];
|
||||
const char * Ex_fmt;
|
||||
};
|
||||
|
||||
extern struct lc_time_T _time_localebuf;
|
||||
|
Loading…
x
Reference in New Issue
Block a user