Some stftime.3 and nl_langinfo.3 updates
PATCH 1/1 Some stftime.3 and nl_langinfo.3 updates
Hello.
There are some additions that cross-link these two pages and aim to make the behaviour of a libc more clear with respect to locale-dependent conversion specifications. It is based on POSIX[1], GNU C Library documentation[2], and glibc's implementation[3], with some cross-checking of uClibc, musl, and FreeBSD implementations.
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html
[2] https://www.gnu.org/software/libc/manual/html_node/The-Elegant-and-Fast-Way.html
[3] https://sourceware.org/git/?p=glibc.git;a=blob;f=time/strftime_l.c
Eugene Syromyatnikov (7):
nl_langinfo.3: mention the respective strftime conversion
specifications
nl_langinfo.3: add information about AM/PM time format locale elements nl_langinfo.3: document era-related locale elements strftime.3: ffix
strftime.3: consistently document fall-back format string strftime.3: refer to the relevant nl_langinfo items strftime.3: expand %E and %O description
man3/nl_langinfo.3 | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++-- man3/strftime.3 | 106 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 232 insertions(+), 9 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/1 nl_langinfo.3: add information about AM/PM time format locale elements
* man3/nl_langinfo.3 (.SH DESCRIPTION): Add description for AM_STR, PM_STR, T_FMT_AMPM locale elements.
--- man3/nl_langinfo.3 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
man3/nl_langinfo.3 +23 -0
@@ -96,6 +96,29 @@ to represent a time in a locale-specific way .RB ( %X conversion specification). .TP +.BR AM_STR \ (LC_TIME) +Return a string that represents affix for ante meridiem (before noon, "AM") +time. +(Used in +.B %p +.BR strftime (3) +conversion specification.) +.TP +.BR PM_STR \ (LC_TIME) +Return a string that represents affix for post meridiem (before midnight, "PM") +time. +(Used in +.B %p +.BR strftime (3) +conversion specification.) +.TP +.BR T_FMT_AMPM \ (LC_TIME) +Return a string that can be used as a format string for +.BR strftime (3) +to represent a time in a.m. or p.m. notation a locale-specific way +.RB ( %r +conversion specification). +.TP .BR DAY_ "{1\(en7} (LC_TIME)" Return name of the \fIn\fP-th day of the week. [Warning: this follows the US convention DAY_1 = Sunday, not the international convention
Signature · 1 line
2.1.4
Re: [PATCH] nl_langinfo.3: add information about AM/PM time format locale elements
Hello Eugene,
Quoted 2 lines · Eugene Syromyatnikov
* man3/nl_langinfo.3 (.SH DESCRIPTION): Add description for
AM_STR,PM_STR,T_FMT_AMPMlocale elements.
Thanks. Patch applied.
Cheers,
Michael
Quoted 40 lines
Signed-off-by Eugene Syromyatnikov <[email protected]>--- man3/nl_langinfo.3 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)man3/nl_langinfo.3 +23
-0@@ -96,6 +96,29 @@ to represent a time in a locale-specific way .RB ( %X conversion specification). .TP +.BR AM_STR \ (LC_TIME) +Return a string that represents affix for ante meridiem (before noon, "AM") +time. +(Used in +.B %p +.BR strftime (3) +conversion specification.) +.TP +.BR PM_STR \ (LC_TIME) +Return a string that represents affix for post meridiem (before midnight, "PM") +time. +(Used in +.B %p +.BR strftime (3) +conversion specification.) +.TP +.BR T_FMT_AMPM \ (LC_TIME) +Return a string that can be used as a format string for +.BR strftime (3) +to represent a time in a.m. or p.m. notation a locale-specific way +.RB ( %r +conversion specification). +.TP .BR DAY_ "{1\(en7} (LC_TIME)" Return name of the \fIn\fP-th day of the week. [Warning: this follows the US convention DAY_1 = Sunday, not the international convention
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 1/1 nl_langinfo.3: mention the respective strftime conversion specifications
In reply to Eugene Syromyatnikov* man3/nl_langinfo.3 (D_T_FMT, D_FMT, T_FMT, DAY_{1–7}, ABDAY_{1–7}, MON_{1–12}, ABMON_{1–12}): Mention the respective strftime(3) conversion specifications.
--- man3/nl_langinfo.3 | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
man3/nl_langinfo.3 +25 -3
@@ -78,31 +78,53 @@ try "locale \-m" (see .BR D_T_FMT \ (LC_TIME) Return a string that can be used as a format string for .BR strftime (3) -to represent time and date in a locale-specific way. +to represent time and date in a locale-specific way +.RB ( %c +conversion specification). .TP .BR D_FMT \ (LC_TIME) Return a string that can be used as a format string for .BR strftime (3) -to represent a date in a locale-specific way. +to represent a date in a locale-specific way +.RB ( %x +conversion specification). .TP .BR T_FMT \ (LC_TIME) Return a string that can be used as a format string for .BR strftime (3) -to represent a time in a locale-specific way. +to represent a time in a locale-specific way +.RB ( %X +conversion specification). .TP .BR DAY_ "{1\(en7} (LC_TIME)" Return name of the \fIn\fP-th day of the week. [Warning: this follows the US convention DAY_1 = Sunday, not the international convention (ISO 8601) that Monday is the first day of the week.] +(Used in +.B %A +.BR strftime (3) +conversion specification.) .TP .BR ABDAY_ "{1\(en7} (LC_TIME)" Return abbreviated name of the \fIn\fP-th day of the week. +(Used in +.B %a +.BR strftime (3) +conversion specification.) .TP .BR MON_ "{1\(en12} (LC_TIME)" Return name of the \fIn\fP-th month. +(Used in +.B %B +.BR strftime (3) +conversion specification.) .TP .BR ABMON_ "{1\(en12} (LC_TIME)" Return abbreviated name of the \fIn\fP-th month. +(Used in +.B %b +.BR strftime (3) +conversion specification.) .TP .BR RADIXCHAR \ (LC_NUMERIC) Return radix character (decimal dot, decimal comma, etc.).
Signature · 1 line
2.1.4
Re: [PATCH] nl_langinfo.3: mention the respective strftime conversion specifications
Hello Eugene,
Quoted 3 lines · Eugene Syromyatnikov
* man3/nl_langinfo.3 (
D_T_FMT,D_FMT,T_FMT, DAY_{1–7}, ABDAY_{1–7}, MON_{1–12}, ABMON_{1–12}): Mention the respective strftime(3) conversion specifications.
Thanks,
Patch applied.
Cheers,
Michael
Quoted 67 lines
Signed-off-by Eugene Syromyatnikov <[email protected]>--- man3/nl_langinfo.3 | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)man3/nl_langinfo.3 +25
-3@@ -78,31 +78,53 @@ try "locale \-m" (see .BR D_T_FMT \ (LC_TIME) Return a string that can be used as a format string for .BR strftime (3) -to represent time and date in a locale-specific way. +to represent time and date in a locale-specific way +.RB ( %c +conversion specification). .TP .BR D_FMT \ (LC_TIME) Return a string that can be used as a format string for .BR strftime (3) -to represent a date in a locale-specific way. +to represent a date in a locale-specific way +.RB ( %x +conversion specification). .TP .BR T_FMT \ (LC_TIME) Return a string that can be used as a format string for .BR strftime (3) -to represent a time in a locale-specific way. +to represent a time in a locale-specific way +.RB ( %X +conversion specification). .TP .BR DAY_ "{1\(en7} (LC_TIME)" Return name of the \fIn\fP-th day of the week. [Warning: this follows the US convention DAY_1 = Sunday, not the international convention (ISO 8601) that Monday is the first day of the week.] +(Used in +.B %A +.BR strftime (3) +conversion specification.) .TP .BR ABDAY_ "{1\(en7} (LC_TIME)" Return abbreviated name of the \fIn\fP-th day of the week. +(Used in +.B %a +.BR strftime (3) +conversion specification.) .TP .BR MON_ "{1\(en12} (LC_TIME)" Return name of the \fIn\fP-th month. +(Used in +.B %B +.BR strftime (3) +conversion specification.) .TP .BR ABMON_ "{1\(en12} (LC_TIME)" Return abbreviated name of the \fIn\fP-th month. +(Used in +.B %b +.BR strftime (3) +conversion specification.) .TP .BR RADIXCHAR \ (LC_NUMERIC) Return radix character (decimal dot, decimal comma, etc.).
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 1/1 nl_langinfo.3: document era-related locale elements
In reply to Eugene SyromyatnikovInformation is mostly taken from POSIX[1], GNU C Library documentation[2], glibc strftime implementation[3], and Japanese locale definition[4].
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_05_02
[2] https://www.gnu.org/software/libc/manual/html_node/The-Elegant-and-Fast-Way.html
[3] https://sourceware.org/git/?p=glibc.git;a=blob;f=time/strftime_l.c
[4] https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/locales/ja_JP
* man3/nl_langinfo.3 (.SH DESCRIPTION): Add information about ERA, ERA_D_T_FMT, ERA_D_FMT, and ERA_T_FMT locale elements.
--- man3/nl_langinfo.3 | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
man3/nl_langinfo.3 +84 -0
@@ -119,6 +119,90 @@ to represent a time in a.m. or p.m. notation a locale-specific way .RB ( %r conversion specification). .TP +.BR ERA \ (LC_TIME) +Return era description, that contains information how years are counted +and displayed for each era in a locale. +Each era description segment shall have the format: +.RS +.IP +.IR direction : offset : start_date : end_date : era_name : era_format +.RE +.IP +according to the definitions below: +.RS +.TP 12 +.I direction +Either a +.RB \[dq] + "\[dq] or a \[dq]" - \[dq] +character. +The +.RB \[dq] + \[dq] +means that years increase from the +.I start_date +towards the +.IR end_date , +.RB \[dq] - \[dq] +means the opposite. +.TP +.I offset +The epoch year of the +.IR start_date . +.TP +.I start_date +A date in the form +.IR yyyy / mm / dd , +where +.IR yyyy ", " mm ", and " dd +are the year, month, and day numbers respectively of the start of the era. +.TP +.I end_date +The ending date of the era, in the same format as the +.IR start_date , +or one of the two special values +.RB \[dq] -* \[dq] +(minus infinity) or +.RB \[dq] +* \[dq] +(plus infinity). +.TP +.I era_name +The name of the era, corresponding to the +.B %EC +.BR strftime (3) +conversion specification. +.TP +.I era_format +The format of the year in the era, corresponding to the +.B %EY +.BR strftime (3) +conversion specification. +.RE +.IP +Era description segments are separated by semicolons. +Most locales do not define this value. +Examples of locales that do define this value are the Japanese and the Thai +locales. +.TP +.BR ERA_D_T_FMT \ (LC_TIME) +Return a string that can be used as a format string for +.BR strftime (3) +for alternative representation of time and date in a locale-specific way +.RB ( %Ec +conversion specification). +.TP +.BR ERA_D_FMT \ (LC_TIME) +Return a string that can be used as a format string for +.BR strftime (3) +for alternative representation of a date in a locale-specific way +.RB ( %Ex +conversion specification). +.TP +.BR ERA_T_FMT \ (LC_TIME) +Return a string that can be used as a format string for +.BR strftime (3) +for alternative representation of a time in a locale-specific way +.RB ( %EX +conversion specification). +.TP .BR DAY_ "{1\(en7} (LC_TIME)" Return name of the \fIn\fP-th day of the week. [Warning: this follows the US convention DAY_1 = Sunday, not the international convention
Signature · 1 line
2.1.4
Re: [PATCH] nl_langinfo.3: document era-related locale elements
Hello Eugene,
Quoted 2 lines · Eugene Syromyatnikov
Information is mostly taken from POSIX[1], GNU C Library documentation[2], glibc strftime implementation[3], and Japanese locale definition[4].
Thanks. Patch applied.
Cheers,
Michael
Quoted 109 lines
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_05_02
[2] https://www.gnu.org/software/libc/manual/html_node/The-Elegant-and-Fast-Way.html
[3] https://sourceware.org/git/?p=glibc.git;a=blob;f=time/strftime_l.c
[4] https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/locales/ja_JP* man3/nl_langinfo.3 (.SH DESCRIPTION): Add information about ERA,
ERA_D_T_FMT,ERA_D_FMT, andERA_T_FMTlocale elements.Signed-off-by Eugene Syromyatnikov <[email protected]>--- man3/nl_langinfo.3 | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)man3/nl_langinfo.3 +84
-0@@ -119,6 +119,90 @@ to represent a time in a.m. or p.m. notation a locale-specific way .RB ( %r conversion specification). .TP +.BR ERA \ (LC_TIME) +Return era description, that contains information how years are counted +and displayed for each era in a locale. +Each era description segment shall have the format: +.RS +.IP +.IR direction : offset : start_date : end_date : era_name : era_format +.RE +.IP +according to the definitions below: +.RS +.TP 12 +.I direction +Either a +.RB \[dq] + "\[dq] or a \[dq]" - \[dq] +character. +The +.RB \[dq] + \[dq] +means that years increase from the +.I start_date +towards the +.IR end_date , +.RB \[dq] - \[dq] +means the opposite. +.TP +.I offset +The epoch year of the +.IR start_date . +.TP +.I start_date +A date in the form +.IR yyyy / mm / dd , +where +.IR yyyy ", " mm ", and " dd +are the year, month, and day numbers respectively of the start of the era. +.TP +.I end_date +The ending date of the era, in the same format as the +.IR start_date , +or one of the two special values +.RB \[dq] -* \[dq] +(minus infinity) or +.RB \[dq] +* \[dq] +(plus infinity). +.TP +.I era_name +The name of the era, corresponding to the +.B %EC +.BR strftime (3) +conversion specification. +.TP +.I era_format +The format of the year in the era, corresponding to the +.B %EY +.BR strftime (3) +conversion specification. +.RE +.IP +Era description segments are separated by semicolons. +Most locales do not define this value. +Examples of locales that do define this value are the Japanese and the Thai +locales. +.TP +.BR ERA_D_T_FMT \ (LC_TIME) +Return a string that can be used as a format string for +.BR strftime (3) +for alternative representation of time and date in a locale-specific way +.RB ( %Ec +conversion specification). +.TP +.BR ERA_D_FMT \ (LC_TIME) +Return a string that can be used as a format string for +.BR strftime (3) +for alternative representation of a date in a locale-specific way +.RB ( %Ex +conversion specification). +.TP +.BR ERA_T_FMT \ (LC_TIME) +Return a string that can be used as a format string for +.BR strftime (3) +for alternative representation of a time in a locale-specific way +.RB ( %EX +conversion specification). +.TP .BR DAY_ "{1\(en7} (LC_TIME)" Return name of the \fIn\fP-th day of the week. [Warning: this follows the US convention DAY_1 = Sunday, not the international convention
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 1/1 strftime.3: ffix
In reply to Eugene Syromyatnikov* man3/strftime.3 (%s): Format "mktime" with .B and not .I.
--- man3/strftime.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man3/strftime.3 +1 -1
@@ -255,7 +255,7 @@ below. .B %s The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). (TZ) (Calculated from -.IR mktime(tm) .) +.BR mktime ( \fItm\fR ).) .TP .B %S The second as a decimal number (range 00 to 60).
Signature · 1 line
2.1.4
Re: [PATCH] strftime.3: ffix
Hi Eugene,
Quoted 12 lines · Eugene Syromyatnikov
* man3/strftime.3 (%s): Format "mktime" with .B and not .I.
Signed-off-by Eugene Syromyatnikov <[email protected]>--- man3/strftime.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)man3/strftime.3 +0
-0
man3/strftime.3 below. · line 258
Quoted 5 lines
man3/strftime.3 +1
-1@@ -255,7 +255,7 @@ below. .B %s The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). (TZ) (Calculated from -.IR mktime(tm) .) +.BR mktime ( \fItm\fR ).)
The usual convention here is .IR. .BR is used for page cross-references (e.g., ".BR mktime (3)"). (But, that said, it would not surprise me if there were some inconsistencies in existing pages.)
Thanks,
Michael
Quoted 4 lines
man3/strftime.3 +0
-0.TP .B %S The second as a decimal number (range 00 to 60).
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 1/1 strftime.3: consistently document fall-back format string
In reply to Eugene SyromyatnikovThe information is taken from POSIX[1] and the implementations[2][3][4].
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_05_03
[2] https://sourceware.org/git/?p=glibc.git;a=blob;f=time/strftime_l.c
[3] https://git.musl-libc.org/cgit/musl/tree/src/locale/langinfo.c#n15
[4] https://git.uclibc.org/uClibc/tree/libc/misc/locale/locale.c#n992
* man3/strftime.3 (%c, %x, %X): Add information about fall-back format. (%r): Move it behind SU comment.
--- man3/strftime.3 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
man3/strftime.3 +8 -2
@@ -107,6 +107,8 @@ The full month name according to the current locale. .TP .B %c The preferred date and time representation for the current locale. +(In the POSIX locale this is equivalent to +.BR "%a %b %e %H:%M:%S %Y" .) .TP .B %C The century number (year/100) as a 2-digit integer. (SU)
@@ -240,9 +242,9 @@ string for the current locale. .TP .B %r The time in a.m. or p.m. notation. -In the POSIX locale this is equivalent to -.BR "%I:%M:%S %p" . (SU) +(In the POSIX locale this is equivalent to +.BR "%I:%M:%S %p" .) .TP .B %R The time in 24-hour notation
@@ -324,9 +326,13 @@ and .TP .B %x The preferred date representation for the current locale without the time. +(In the POSIX locale this is equivalent to +.BR %m/%d/%y .) .TP .B %X The preferred time representation for the current locale without the date. +(In the POSIX locale this is equivalent to +.BR %H:%M:%S .) .TP .B %y The year as a decimal number without a century (range 00 to 99).
Signature · 1 line
2.1.4
Re: [PATCH] strftime.3: consistently document fall-back format string
Hello Eugene,
Quoted 1 line · Eugene Syromyatnikov
The information is taken from POSIX[1] and the implementations[2][3][4].
Thanks. Patch applied.
Cheers,
Michael
Quoted 53 lines
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_05_03
[2] https://sourceware.org/git/?p=glibc.git;a=blob;f=time/strftime_l.c
[3] https://git.musl-libc.org/cgit/musl/tree/src/locale/langinfo.c#n15
[4] https://git.uclibc.org/uClibc/tree/libc/misc/locale/locale.c#n992* man3/strftime.3 (%c, %x, %X): Add information about fall-back format. (%r): Move it behind SU comment.
Signed-off-by Eugene Syromyatnikov <[email protected]>--- man3/strftime.3 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)man3/strftime.3 +8
-2@@ -107,6 +107,8 @@ The full month name according to the current locale. .TP .B %c The preferred date and time representation for the current locale. +(In the POSIX locale this is equivalent to +.BR "%a %b %e %H:%M:%S %Y" .) .TP .B %C The century number (year/100) as a 2-digit integer. (SU)@@ -240,9 +242,9 @@ string for the current locale. .TP .B %r The time in a.m. or p.m. notation. -In the POSIX locale this is equivalent to -.BR "%I:%M:%S %p" . (SU) +(In the POSIX locale this is equivalent to +.BR "%I:%M:%S %p" .) .TP .B %R The time in 24-hour notation@@ -324,9 +326,13 @@ and .TP .B %x The preferred date representation for the current locale without the time. +(In the POSIX locale this is equivalent to +.BR %m/%d/%y .) .TP .B %X The preferred time representation for the current locale without the date. +(In the POSIX locale this is equivalent to +.BR %H:%M:%S .) .TP .B %y The year as a decimal number without a century (range 00 to 99).
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 1/1 strftime.3: refer to the relevant nl_langinfo items
In reply to Eugene SyromyatnikovAs it wasn't clear before where this kind of information can be obtained from.
* man3/strftime.3 (%a, %A, %b, %B, %c, %p, %r, %x, %X): Add information about the locale elements that can be used to retrieve the relevant information using nl_langinfo() library call.
--- man3/strftime.3 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
man3/strftime.3 +65 -0
@@ -89,24 +89,55 @@ structure are also shown. The abbreviated name of the day of the week according to the current locale. (Calculated from .IR tm_wday .) +(The specific names used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR ABDAY_ { 1 \(en 7 } +as an argument.) .TP .B %A The full name of the day of the week according to the current locale. (Calculated from .IR tm_wday .) +(The specific names used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR DAY_ { 1 \(en 7 } +as an argument.) .TP .B %b The abbreviated month name according to the current locale. (Calculated from .IR tm_mon .) +(The specific names used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR ABMON_ { 1 \(en 12 } +as an argument.) .TP .B %B The full month name according to the current locale. (Calculated from .IR tm_mon .) +(The specific names used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR MON_ { 1 \(en 12 } +as an argument.) .TP .B %c The preferred date and time representation for the current locale. +(The specific format used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.B D_T_FMT +as an argument for the +.B %c +conversion specification, and with +.B ERA_D_T_FMT +for the +.B %Ec +conversion specification.) (In the POSIX locale this is equivalent to .BR "%a %b %e %H:%M:%S %Y" .) .TP
@@ -230,6 +261,12 @@ corresponding strings for the current locale. Noon is treated as "PM" and midnight as "AM". (Calculated from .IR tm_hour .) +(The specific string representations used for "AM" and "PM" +in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR AM_STR " and " PM_STR , +respectively.) .TP .B %P Like
@@ -243,6 +280,11 @@ string for the current locale. .B %r The time in a.m. or p.m. notation. (SU) +(The specific format used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.B T_FMT_AMPM +as an argument.) (In the POSIX locale this is equivalent to .BR "%I:%M:%S %p" .) .TP
@@ -326,11 +368,33 @@ and .TP .B %x The preferred date representation for the current locale without the time. +(The specific format used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.B D_FMT +as an argument for the +.B %x +conversion specification, and with +.B ERA_D_FMT +for the +.B %Ex +conversion specification.) (In the POSIX locale this is equivalent to .BR %m/%d/%y .) .TP .B %X The preferred time representation for the current locale without the date. +(The specific format used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.B T_FMT +as an argument for the +.B %X +conversion specification, and with +.B ERA_T_FMT +for the +.B %EX +conversion specification.) (In the POSIX locale this is equivalent to .BR %H:%M:%S .) .TP
@@ -657,6 +721,7 @@ main(int argc, char *argv[]) .BR date (1), .BR time (2), .BR ctime (3), +.BR nl_langinfo (3), .BR setlocale (3), .BR sprintf (3), .BR strptime (3)
Signature · 1 line
2.1.4
Re: [PATCH] strftime.3: refer to the relevant nl_langinfo items
Hello Eugene,
Quoted 6 lines · Eugene Syromyatnikov
As it wasn't clear before where this kind of information can be obtained from.
* man3/strftime.3 (%a, %A, %b, %B, %c, %p, %r, %x, %X): Add information about the locale elements that can be used to retrieve the relevant information using
nl_langinfo()library call.
Thanks. Patch applied.
Cheers,
Michael
Quoted 133 lines
Signed-off-by Eugene Syromyatnikov <[email protected]>--- man3/strftime.3 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)man3/strftime.3 +65
-0@@ -89,24 +89,55 @@ structure are also shown. The abbreviated name of the day of the week according to the current locale. (Calculated from .IR tm_wday .) +(The specific names used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR ABDAY_ { 1 \(en 7 } +as an argument.) .TP .B %A The full name of the day of the week according to the current locale. (Calculated from .IR tm_wday .) +(The specific names used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR DAY_ { 1 \(en 7 } +as an argument.) .TP .B %b The abbreviated month name according to the current locale. (Calculated from .IR tm_mon .) +(The specific names used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR ABMON_ { 1 \(en 12 } +as an argument.) .TP .B %B The full month name according to the current locale. (Calculated from .IR tm_mon .) +(The specific names used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR MON_ { 1 \(en 12 } +as an argument.) .TP .B %c The preferred date and time representation for the current locale. +(The specific format used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.B D_T_FMT +as an argument for the +.B %c +conversion specification, and with +.B ERA_D_T_FMT +for the +.B %Ec +conversion specification.) (In the POSIX locale this is equivalent to .BR "%a %b %e %H:%M:%S %Y" .) .TP@@ -230,6 +261,12 @@ corresponding strings for the current locale. Noon is treated as "PM" and midnight as "AM". (Calculated from .IR tm_hour .) +(The specific string representations used for "AM" and "PM" +in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.BR AM_STR " and " PM_STR , +respectively.) .TP .B %P Like@@ -243,6 +280,11 @@ string for the current locale. .B %r The time in a.m. or p.m. notation. (SU) +(The specific format used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.B T_FMT_AMPM +as an argument.) (In the POSIX locale this is equivalent to .BR "%I:%M:%S %p" .) .TP@@ -326,11 +368,33 @@ and .TP .B %x The preferred date representation for the current locale without the time. +(The specific format used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.B D_FMT +as an argument for the +.B %x +conversion specification, and with +.B ERA_D_FMT +for the +.B %Ex +conversion specification.) (In the POSIX locale this is equivalent to .BR %m/%d/%y .) .TP .B %X The preferred time representation for the current locale without the date. +(The specific format used in the current locale can be obtained by calling +.BR nl_langinfo (3) +library call with +.B T_FMT +as an argument for the +.B %X +conversion specification, and with +.B ERA_T_FMT +for the +.B %EX +conversion specification.) (In the POSIX locale this is equivalent to .BR %H:%M:%S .) .TP@@ -657,6 +721,7 @@ main(int argc, char *argv[]) .BR date (1), .BR time (2), .BR ctime (3), +.BR nl_langinfo (3), .BR setlocale (3), .BR sprintf (3), .BR strptime (3)
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 1/1 strftime.3: expand %E and %O description
In reply to Eugene Syromyatnikov* man3/strftime.3 (%C): Descibe the meaning of %EC conversion specification.
(%E): Mention the concept of "era" in description.
(%O): Mention that alternative format is related to numeric representation.
(%y): Describe the meaning of %Ey conversion specification. (%Y): Describe the meaning of %EY conversion specification. (.SH DESCRIPTION): Mention that the behaviour of %E modifier is governed by ERA locale element and provide ja_JP locale as an example.
--- man3/strftime.3 | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
man3/strftime.3 +26 -3
@@ -143,6 +143,9 @@ conversion specification.) .TP .B %C The century number (year/100) as a 2-digit integer. (SU) +(The +.B %EC +conversion specification corresponds to the name of the era.) (Calculated from .IR tm_year .) .TP
@@ -170,7 +173,7 @@ zero is replaced by a space. (SU) .IR tm_mday .) .TP .B %E -Modifier: use alternative format, see below. (SU) +Modifier: use alternative ("era-based") format, see below. (SU) .TP .B %F Equivalent to
@@ -253,7 +256,7 @@ The minute as a decimal number (range 00 to 59). A newline character. (SU) .TP .B %O -Modifier: use alternative format, see below. (SU) +Modifier: use alternative numeric symbols, see below. (SU) .TP .B %p Either "AM" or "PM" according to the given time value, or the
@@ -400,11 +403,20 @@ conversion specification.) .TP .B %y The year as a decimal number without a century (range 00 to 99). +(The +.B %Ey +conversion specification corresponds to the year since the beginning of the era +denoted by +.B %EC +conversion specification.) (Calculated from .IR tm_year ) .TP .B %Y The year as a decimal number including the century. +(The +.B %EY +conversion specification corresponds to the full alternative year representation.) (Calculated from .IR tm_year ) .TP
@@ -463,7 +475,18 @@ where the effect of the .B O modifier is to use alternative numeric symbols (say, roman numerals), and that of the -E modifier is to use a locale-dependent alternative representation. +.B E +modifier is to use a locale-dependent alternative representation. +The rules governing date representation with the +.B E +modifier can be obtained by supplying +.B ERA +as an argument to a +.BR nl_langinfo (3) +library call. +One example of such alternative forms is Japanese era calendar scheme in the +.B ja_JP +glibc locale. .SH RETURN VALUE Provided that the result string, including the terminating null byte, does not exceed
Signature · 1 line
2.1.4
Re: [PATCH] strftime.3: expand %E and %O description
Hello Eugene,
Quoted 11 lines · Eugene Syromyatnikov
* man3/strftime.3 (%C): Descibe the meaning of %EC conversion specification.
(%E): Mention the concept of "era" in description.
(%O): Mention that alternative format is related to numeric representation.
(%y): Describe the meaning of %Ey conversion specification. (%Y): Describe the meaning of %EY conversion specification. (.SH DESCRIPTION): Mention that the behaviour of %E modifier is governed by ERA locale element and provideja_JPlocale as an example.Signed-off-by Eugene Syromyatnikov <[email protected]>
Thanks! Patch applied.
Cheers,
Michael
Quoted 78 lines
--- man3/strftime.3 | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)man3/strftime.3 +26
-3@@ -143,6 +143,9 @@ conversion specification.) .TP .B %C The century number (year/100) as a 2-digit integer. (SU) +(The +.B %EC +conversion specification corresponds to the name of the era.) (Calculated from .IR tm_year .) .TP@@ -170,7 +173,7 @@ zero is replaced by a space. (SU) .IR tm_mday .) .TP .B %E -Modifier: use alternative format, see below. (SU) +Modifier: use alternative ("era-based") format, see below. (SU) .TP .B %F Equivalent to@@ -253,7 +256,7 @@ The minute as a decimal number (range 00 to 59). A newline character. (SU) .TP .B %O -Modifier: use alternative format, see below. (SU) +Modifier: use alternative numeric symbols, see below. (SU) .TP .B %p Either "AM" or "PM" according to the given time value, or the@@ -400,11 +403,20 @@ conversion specification.) .TP .B %y The year as a decimal number without a century (range 00 to 99). +(The +.B %Ey +conversion specification corresponds to the year since the beginning of the era +denoted by +.B %EC +conversion specification.) (Calculated from .IR tm_year ) .TP .B %Y The year as a decimal number including the century. +(The +.B %EY +conversion specification corresponds to the full alternative year representation.) (Calculated from .IR tm_year ) .TP@@ -463,7 +475,18 @@ where the effect of the .B O modifier is to use alternative numeric symbols (say, roman numerals), and that of the -E modifier is to use a locale-dependent alternative representation. +.B E +modifier is to use a locale-dependent alternative representation. +The rules governing date representation with the +.B E +modifier can be obtained by supplying +.B ERA +as an argument to a +.BR nl_langinfo (3) +library call. +One example of such alternative forms is Japanese era calendar scheme in the +.B ja_JP +glibc locale. .SH RETURN VALUE Provided that the result string, including the terminating null byte, does not exceed
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/