%Ex -> %Ef to not conflict with POSIX

Add %EF (long months name / day order)
Check that O and E not intermixed
Add missing POSIX extension to example
This commit is contained in:
Andrey A. Chernov 1999-11-30 19:24:07 +00:00
parent a36840a71a
commit c63a4303ab
5 changed files with 53 additions and 13 deletions

View File

@ -106,12 +106,16 @@ is replaced by the day of the month as a decimal number (01-31).
.It Cm \&%E* Cm \&%O*
POSIX locale extensions.
The sequences
%Ec %EC %Ex %Ey %EY
%Ec %EC %Ex %EX %Ey %EY
%Od %Oe %OH %OI %Om %OM
%OS %Ou %OU %OV %Ow %OW %Oy
are supposed to provide alternate
representations. Currently %Ex implemented to represent short month name / day
order of the date and %OB to represent alternative months names
representations.
.Pp
Additionly %Ef implemented to represent short month name / day
order of the date, %EF to represent long month name / day
order
and %OB to represent alternative months names
(used standalone, without day mentioned).
.It Cm %e
is replaced by the day of month as a decimal number (1-31); single

View File

@ -129,6 +129,8 @@ label:
pt = _conv(t->tm_mday, "%02d", pt, ptlim);
continue;
case 'E':
if (Ealternative || Oalternative)
break;
Ealternative++;
goto label;
case 'O':
@ -136,18 +138,33 @@ label:
** POSIX locale extensions, a la
** Arnold Robbins' strftime version 3.0.
** The sequences
** %Ec %EC %Ex %Ey %EY
** %Ec %EC %Ex %EX %Ey %EY
** %Od %oe %OH %OI %Om %OM
** %OS %Ou %OU %OV %Ow %OW %Oy
** are supposed to provide alternate
** representations.
** (ado, 5/24/93)
**
** FreeBSD extensions
** %OB %Ef %EF
*/
if (Ealternative || Oalternative)
break;
Oalternative++;
goto label;
case 'e':
pt = _conv(t->tm_mday, "%2d", pt, ptlim);
continue;
case 'f':
if (!Ealternative)
break;
pt = _fmt(Locale->Ef_fmt, t, pt, ptlim);
continue;
case 'F':
if (!Ealternative)
break;
pt = _fmt(Locale->EF_fmt, t, pt, ptlim);
continue;
case 'H':
pt = _conv(t->tm_hour, "%02d", pt, ptlim);
continue;
@ -361,7 +378,7 @@ label:
pt = _fmt(Locale->X_fmt, t, pt, ptlim);
continue;
case 'x':
pt = _fmt(Ealternative ? Locale->Ex_fmt : Locale->x_fmt, t, pt, ptlim);
pt = _fmt(Locale->x_fmt, t, pt, ptlim);
continue;
case 'y':
pt = _conv((t->tm_year + TM_YEAR_BASE) % 100,

View File

@ -152,13 +152,26 @@ label:
break;
case 'E':
if (Ealternative || Oalternative)
break;
Ealternative++;
goto label;
case 'O':
if (Ealternative || Oalternative)
break;
Oalternative++;
goto label;
case 'F':
case 'f':
if (!Ealternative)
break;
buf = _strptime(buf, (c == 'f') ? Locale->Ef_fmt : Locale->EF_fmt, tm);
if (buf == 0)
return 0;
break;
case 'R':
buf = _strptime(buf, "%H:%M", tm);
if (buf == 0)
@ -184,7 +197,7 @@ label:
break;
case 'x':
buf = _strptime(buf, Ealternative ? Locale->Ex_fmt : Locale->x_fmt, tm);
buf = _strptime(buf, Locale->x_fmt, tm);
if (buf == 0)
return 0;
break;

View File

@ -47,7 +47,7 @@ int _time_using_locale;
#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 *))
(offsetof(struct lc_time_T, Ef_fmt) / sizeof(char *))
const struct lc_time_T _C_time_locale = {
{
@ -82,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 %Ex %X %Y",
"%a %Ef %X %Y",
/* am */
"AM",
@ -91,17 +91,22 @@ const struct lc_time_T _C_time_locale = {
"PM",
/* date_fmt */
"%a %Ex %X %Z %Y",
"%a %Ef %X %Z %Y",
{
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
},
/* Ex_fmt
** To determine months / day order
/* Ef_fmt
** To determine short months / day order
*/
"%b %e"
"%b %e",
/* EF_fmt
** To determine long months / day order
*/
"%B %e"
};

View File

@ -42,7 +42,8 @@ struct lc_time_T {
const char * pm;
const char * date_fmt;
const char * alt_month[12];
const char * Ex_fmt;
const char * Ef_fmt;
const char * EF_fmt;
};
extern struct lc_time_T _time_localebuf;