![]() |
![]() |
e-docs > Tuxedo > ATMI C Function Reference > Section 3c - C Functions |
ATMI C Function Reference
|
Name
strftime()—Converts date and time to string.
Synopsis
#include <time.h>
size_t *strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr);
Description
strftime() places characters into the array pointed to by s as controlled by the string pointed to by format. The format string consists of zero or more directives and ordinary characters. All ordinary characters (including the terminating NULL character) are copied unchanged into the array. For strftime(), no more than maxsize characters are placed into the array.
If format is (char *)0, then the locale's default format is used. The default format is the same as "%c".
Each directive is replaced by appropriate characters as described in the following list. The appropriate characters are determined by the LC_TIME category of the program's locale and by the values contained in the structure pointed to by timeptr.
The difference between %U and %W lies in which day is counted as the first of the week. Week number 01 is the first week in January starting with a Sunday for %U or a Monday for %W. Week number 00 contains those days before the first Sunday or Monday in January for %U and %W, respectively. If the total number of resulting characters including the terminating NULL character is not more than maxsize, strftime(), returns the number of characters placed into the array pointed to by s not including the terminating NULL character. Otherwise, zero is returned and the contents of the array are indeterminate. A thread in a multithreaded application may issue a call to strftime() while running in any context state, including TPINVALIDCONTEXT. Selecting the Output Language By default, the output of strftime(), appears in U.S. English. The user can request that the output of strftime() be in a specific language by setting the locale for category LC_TIME in setlocale(). Time Zone The time zone is taken from the environment variable TZ. See ctime(3c) for a description of TZ. Examples The example illustrates the use of strftime(). It shows what the string in str would look like if the structure pointed to by tmptr contains the values corresponding to Thursday, August 28, 1986 at 12:44:36 in New Jersey. This results in str containing "Thursday Aug 28 240". Files $TUXDIR/locale/locale/LANGINFO—file containing compiled locale-specific date and time information See Also
strftime (str, strsize, "%A %b %d %j", tmptr)
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |