ISO/ IEC JTC1/SC22/WG14 N715

                     Document number: SC22/WG14 N715 (J11 97-078)

Title: strftime alignment
Author: Keld Simonsen
Author affiliation: DKUUG
Postal address: Fruebjergvej 3, DK-2100 Kbenhavn 
Email address: keld@dkuug.dk
Telephone number: +45 3122-6543
Fax number: +45 3325-6543
Sponsor: DS
Date: 1997-06-08
Proposal category:
    __ Editorial change/non-normative contribution
    XX Correction
    XX New feature
    __ Addition to obsolescent feature list
    __ Other (please specify)
Area of standard affected:
    XX Environment
    XX Language
    __ Preprocessor
    XX Library
       XX Macro/typedef/tag name
       XX Function
       XX Header
    __ Other (please specify)
Prior art: ISO/IEC 9945 POSIX standards
Target audience: general

Related documents: N431 (Rationale and analysis), N507, N538,
N586, N658, N665
Proposal attached: proposal paper
Review committee: Keld Simonsen, Rex Jaeschke, John Benito,
John Nestor. This draft has not been reviewed by the review
committee due to time constraints.
Status: Stage 2, under consideration by WG14

Abstract: 
The paper gives a proposal for alignment of C9X with the POSIX
standards wrt the strftime function.

Introduction

This paper gives proposals for changes to the C standard to align it
with the POSIX standards POSIX System API (C language) (POSIX-1),
and ISO/IEC 9945-2:1993 POSIX Shell and  Utilities (POSIX-2), with
respect to the strftime function. It does not cover newer proposals
for POSIX or other related specifications, that are not yet
international standards.

It builds on the document N431, which gave an overview of
internationalisation in C and POSIX standards, a comparison of the
functionality and features provided, and also mentioned other
incompatibilities between C and POSIX standards. Thus N431 gave the
background and rationale for the proposed changes, and it was
decided in the Copenhagen meeting to do further work based on N431.
The paper here descibes in detail what the changes should be.

The following section numbers refer to the C9X Draft 8.

7.5.2.1 time lconv variables

In addition to the defined entries, define the following:

abday          Define the abbreviated weekday names, referenced by the
               %a field descriptor. The operand shall consist of an
               array of seven strings. The first string shall be the
               abbreviated name of the first day of the week (Sunday),
               the second the abbreviated name of the second day, and
               so on. The value for the C locale is:
               ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].
day            Define the full weekday names, referenced by the %A
               field descriptor. The operand shall consist of an array
               of seven strings. The first string shall be the full
               name of the first day of the week (Sunday), the second
               the full name of the second day, and so on. The value
               for the C locale is:
               ["Sunday","Monday","Tuesday","Wednesday","Thursday","Fr
               iday","Saturday"]
abmon          Define the abbreviated month names, referenced by the
               %b field descriptor. The operand shall consist of an
               array of twelve strings. The first string shall be the
               abbreviated name of the first month of the year
               (January), the second the abbreviated name of the
               second month, and so on. The value for the C locale is:
               ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep",
               "Oct","Nov","Dec"]
mon            Define the full month names, referenced by the %B field
               descriptor. The operand shall consist of an array of
               twelve strings. The first string shall be the full name
               of the first month of the year (January), the second
               the full name of the second month, and so on. The value
               for the C locale is:
               ["January","February","March","April","May","June","Jul
               y","August","Septembeer","October","November","December
               "]
d_t_fmt        Define the appropriate date and time representation,
               referenced by the %c field descriptor. The operand
               shall consist of a string, and can contain any
               combination of characters and field descriptors. In ad-
               dition, the string can contain escape sequences defined
               in Table 2. The value for the C locale is: "%a %b %e %T
               %Y".
d_fmt          Define the appropriate date representation, referenced
               by the %x field descriptor. The operand shall consist
               of a string, and can contain any combination of
               characters and field descriptors. In addition, the
               string can contain escape sequences defined in Table 2.
               The value for the C locale is: "%m/%d/%y".
t_fmt          Define the appropriate time representation, referenced
               by the %X field descriptor. The operand shall consist
               of a string, and can contain any combination of
               characters and field descriptors. In addition, the
               string can contain escape sequences defined in Table 2.
               The value for the C locale is "%T".
am_pm          Define the appropriate representation of the ante
               meridiem and post meridiem strings, referenced by the
               %p field descriptor. The operand shall consist of an
               array of two strings. The first string shall represent
               the antemeridiem designation, the last string the
               postmeridiem designation. The value for the C locale is
               ["",""].
t_fmt_ampm     Define the appropriate time representation in the 12-
               hour clock format with am_pm, referenced by the %r
               field descriptor. The operand shall consist of a string
               and can contain any combination of characters and field
               descriptors. If the string is empty, the 12-hour format
               is not supported in the locale. The value for the C
               locale is "%I:%M:%S %p".

It is implementation defined whether the following optional keywords
shall be recognized. If they are not supported, but present in a
description file, they shall be ignored.

era            Shall be used to define alternate Eras, corresponding
               to the %E field descriptor modifier. The format of the
               operand is unspecified, but shall support the defini-
               tion of the %EC and %Ey field descriptors, and may also
               define the era_year format (%EY).
era_year       Shall be used to define the format of the year in
               alternate Era format, corresponding to the %EY field
               descriptor.
era_d_fmt      Shall be used to define the format of the date in
               alternate Era notation, corresponding to the %Ex field
               descriptor.
alt_digits     Shall be used to define alternate symbols for digits,
               corresponding to the %O field descriptor modifier. The
               operand shall consist of semicolon-separated strings.
               The first string shall be the alternate symbol cor-
               responding with zero, the second string the symbol
               corresponding with one, and so on. Up to 100 alternate
               symbol strings can be specified. The %O modifier
               indicates that the string corresponding to the value
               specified via the field descriptor shall be used
               instead of the value.

7.14.3.5 strftime

The date utility in POSIX-2 4.15 has all of the formats of C's
strftime() plus more, all of which are proposed to be added to
strftime(), ie merged with the current list:

%C      is replaced by the year divided by 100 and truncated to an
        integer, as a decimal number (00-99)
%D      is replaced by the date in the format mm/dd/yy
%e      is replaced by the day of the month as a decimal number (1-31
        in a two-digit field with leading <space> fill)
%f      is replaced by the weekday as a decimal number (1-7), where
        Monday is 1 (according to ISO 8601).
%F      is replaced by the date in the format YYYY-MM-DD (ISO 8601
        format)
%h      a synonym for %b
%n      is replaced by a <newline> character
%r      is replaced by the 12 h clock time (01-12) using the AM/PM
        notation; in the "C" locale, this shall be equivalent to
        "%I:%M:%S %p"
%t      is replaced by a <tab> character
%T      is replaced by the 24 h clock time (00-23) in the format
        HH:MM:SS.
%u      is replaced by the week of the year (Sunday as the first day
        of the week) as a decimal number (00-53). All days in a new
        year preceding the first Sunday shall be considered to be in
        week 0.
%V      is replaced by the week of the year (Monday as the first day
        of the week) as a decimal number (00-53). The method for
        determining the week number shall be as specified in ISO 8601.

A number of modified field descriptors %O<d> and %E<d> are also
defined in POSIX.2 (4.15.4.2). Text to be added for the C standard,
after the "%%" definition:

Some field descriptors can be modified by the E and O modifier
characters to indicate a different format or specification as
specified in the LC_TIME locale description. If the corresponding
data (see era, era_year, era_d_fmt, and alt_digits) is not specified
or not supported for the current locale, the unmodified field
descriptor value shall be used.

%Ec     Locale's alternate date and time representation.
%EC     The name of the base year (period) in the locale's alternate
        representation.
%Ex     Locale's alternate date representation.
%Ey     Offset from %EC (year only) in the locale's alternate
        representation.
%EY     Full alternate year representation.
%Od     Day of month using the locale's alternate numeric symbols.
%Oe     Day of month using the locale's alternate numeric symbols.
%OH     Hour (24-hour clock) using the locale's alternate numeric
        symbols.
%OI     Hour (12-hour clock) using the locale's alternate numeric
        symbols.
%Om     Month using the locale's alternate numeric symbols.
%OM     Minutes using the locale's alternate numeric symbols.
%OS     Seconds using the locale's alternate numeric symbols.
%OU     Week number of the year (Sunday as the first day of the week)
        using the locale's alternate numeric symbols.
%Ow     Weekday as number in the locale's alternate representation
        (Sunday=0).
%OW     Week number of the year (Monday as the first day of the week)
        using the locale's alternate numeric symbols.
%Oy     Year (offset from %C) in alternate representation.


Differences from POSIX

This proposal introduces the following changes from POSIX (all
additions):

Adds %F for ISO 8601 date format.
Adds %f for ISO 8601 weekday numbers.

<END OF DOCUMENT>