Date modifiers explained

datelocale

Again, I found some interesting I don't understand in an info page, in info dateto be precisely:

An optional modifier can follow the optional flag and width
specification. The modifiers are:

E
      Use the locale's alternate representation
for date and time. This modifier applies to the %c, %C, %x,
%X, %y and %Y conversion specifiers. In a Japanese locale, for
example, %Ex might yield a date format based on the Japanese
Emperors' reigns.

O
      Use the locale's alternate numeric
symbols for numbers. This modifier applies only to numeric conversion
specifiers.

If the format supports the modifier but no alternate representation is
available, it is ignored.

Question: An[other] example, how this modifiers are used.

The description sounds to me like »Will do stuff, if other stuff was set, but don't expect too much«. Sometimes I wonder where things like this come from and what their purpose is/was.

Best Answer

I agree with you that there are at times too much choice, but the world is a big place and their are lots of different parties to please, so someone obviously wanted this.

If you look in the libc libraries you'll find this function:

7.6.2 Pinpoint Access to Locale Data

When writing the X/Open Portability Guide the authors realized that the localeconv function is not enough to provide reasonable access to locale information. The information which was meant to be available in the locale (as later specified in the POSIX.1 standard) requires more ways to access it. Therefore the nl_langinfo function was introduced.

— Function: char * nl_langinfo (nl_item item)

The nl_langinfo function can be used to access individual elements of the locale categories. Unlike the localeconv function, which returns all the information, nl_langinfo lets the caller select what information it requires. This is very fast and it is not a problem to call this function multiple times.

A second advantage is that in addition to the numeric and monetary formatting information, information from the LC_TIME and LC_MESSAGES categories is available.

The type nl_type is defined in nl_types.h. The argument item is a numeric value defined in the header langinfo.h. The X/Open standard defines the following values:

One of the nl_items's that you can provide the nl_langinfo function is ERA.

ERA

The return value represents the era used in the current locale. Most locales do not define this value. An example of a locale which does define this value is the Japanese one. In Japan, the traditional representation of dates includes the name of the era corresponding to the then-emperor's reign.

Normally it should not be necessary to use this value directly. Specifying the E modifier in their format strings causes the strftime functions to use this information. The format of the returned string is not specified, and therefore you should not assume knowledge of it on different systems.

source: 7.6.2 Pinpoint Access to Locale Data

Related Question