Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)
strftime(3) Guardian Native C Library Calls Reference Manual
x The short date is output in the format specified for the
current locale.
X The time is output in the format specified for the current
locale.
y The year is output as a number (without the century)
between 00 and 99.
Y The year is output as a number (with the century) between
0000 and 9999.
Z The (standard time or daylight saving time) time-zone name
is output as a string from the environment variable TZ
(CDT, for example). If no time-zone information exists, no
characters are output.
% The % (percent) character is output.
When a conversion code character is not from the preceding list, the behavior of this function is
undefined.
EXAMPLES
The following example shows the use of strftime() to display the current date:
#include <time.h>
#include <locale.h>
#include <stdio.h>
#define SLENGTH 80
main( )
{
char nowstr[SLENGTH];
time_t nowbin;
struct tm *nowstruct;
(void)setlocale(LC_ALL, "");
if (time(&nowbin) == (time_t) - 1)
printf("Could not get time of day from time( )\n");
nowstruct = localtime(&nowbin);
if (strftime(nowstr, SLENGTH, "%A %x", nowstruct) == (size_t) 0)
printf("Could not get string from strftime( )\n");
printf("Today’s date is %s\n", nowstr);
}
NOTES
The %S seconds field can contain a value up to 61 seconds rather than up to 59 seconds to allow
leap seconds that are sometimes added to years to keep clocks in correspondence with the solar
year.
6−64 Hewlett-Packard Company 527192-005