NAME

strftime - convert date and time to a string

SYNOPSIS

#include "zkTime.h"

size_t strftime(char *s, size_t maxsize, const char *format,
    const struct tm *timptr);

DESCRIPTION

The strftime() function places bytes into the array pointed to by s as controlled by the string pointed to by format. The format string consists of zero or more conversion specifications and ordinary characters. A conversion specification consists of a % character and a terminating conversion character that determines the conversion specification's behaviour. All ordinary characters (including the terminating null byte) are copied unchanged into the array. If copying takes place between objects that overlap, the behaviour is undefined. No more than maxsize bytes are placed into the array. Each conversion specification is replaced by appropriate characters as described in the following list. The appropriate characters are determined by the program's locale and by the values contained in the structure pointed to by timptr.

%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.
%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].
%p
is replaced by the locale's equivalent of either a.m. or p.m.
%S
is replaced by the second as a decimal number [00,61].
%U
is replaced by the week number of the year (Sunday as the first day of the week) as a decimal number [00,53].
%w
is replaced by the weekday as a decimal number [0,6], with 0 representing Sunday.
%W
is replaced by the week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.
%x
is replaced by the locale's appropriate date representation.
%X
is replaced by the locale's appropriate time representation.
%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 abbreviation, or by no bytes if no timezone information exists.
%%
is replaced by %.

If a conversion specification does not correspond to any of the above, the behaviour is undefined.

RETURN VALUE

If the total number of resulting bytes including the terminating null byte is not more than maxsize, strftime() returns the number of bytes placed into the array pointed to by s, not including the terminating null byte. Otherwise, 0 is returned and the contents of the array are indeterminate.

ERRORS

No errors are defined.

APPLICATION USAGE

Applications should use %Y (4-digit years) in preference to %y (2-digit years).