Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ strftim(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ctime(S)

timtbl(M)


 strftime(S)                    6 January 1993                    strftime(S)


 Name

    strftime - format date/time string

 Syntax


    cc  . . .  -lintl


    #include  <time.h>

    int strftime(s, maxsize, format, timeptr)
    char *s;
    int maxsize;
    char *format;
    struct tm *timeptr;


 Description

    The strftime function places its output (according to the format string
    format and the time values contained in the structure pointed to by
    timeptr), followed by the null character (\0) in consecutive bytes
    starting at s.  The maximum length of the output string is specified by
    maxsize, the maximum number of characters including the terminating null
    character.

    The strftime function converts and formats the time values contained in
    the structure pointed to by timeptr under control of the format string
    format.  The string format is a character string can contain two types of
    object. These are: plain characters, which are simply copied to the out-
    put string, and directives.

    Each directive is introduced by the percent character (%).  The following
    directives are independent of the program's current locale (see
    locale(M)):


    %d   is replaced by the day of the month as a decimal number (01-31)

    %H   is replaced by the hour (24-hour clock) as a decimal number (00-23)

    %I   is replaced by the hour (12-hour clock) as a decimal number (01-12)

    %j   is replaced by the day of the year as a decimal number (001-366)

    %m   is replaced by the month as a decimal number (01-12)

    %M   is replaced by the minute as a decimal number (00-59)

    %S   is replaced by the second as a decimal number (00-59)

    %U   is replaced by the week number of the year (Sunday as the first day
         of the week) as a decimal number (00-52)

    %w   is replaced by the weekday as a decimal number [0(Sunday)-6]

    %W   is replaced by the week number of the year (Monday as the first day
         of the week) as a decimal number (00-52)

    %y   is replaced by the year without century as a decimal number (00-99)

    %Y   is replaced by the year with century as a decimal number

    %Z   is replaced by the timezone name, or by no characters if no timezone
         exists

    %%   is replaced by %

    The strings used to replace the following directives are dependent on the
    program's current locale, and are defined using the utility timtbl(M)):


    %a   is replaced by the locale's abbreviated weekday name

    %A   is replaced by the locale's full weekday name

    %b   is replaced by the locale's abbreviated month name

    %B   is replaced by the locale's full month name

    %c   is replaced by the locale's appropriate date and time representation

    %p   is replaced by the locale's equivalent of AM orPM

    %x   is replaced by the locale's appropriate date representation

    %X   is replaced by the locale's appropriate time representation


 Return value

    The function returns the number of characters placed in the string s (not
    including the terminating null character), or zero if the length of the
    output string would exceed maxsize.  In the latter case, the content of
    the output string s is undefined.

    Zero is also returned if the function detects a situation which would
    lead to infinite recursion; for example, if a format string refers to
    itself.

 See also

    ctime(S),

    nlcxtime(S), timtbl(M)

 Standards conformance

    strftime is conformant with:
    ANSI X3.159-1989 Programming Language -- C;
    IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C
    Language] (ISO/IEC 9945-1);
    and NIST FIPS 151-1.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026