NLstrtime
Purpose
Formats time and date.
Syntax
int NLstrtime (str, len, format, tmdate)
char *str, *format;
int len;
struct tm *tmdate;
Description
The NLstrtime subroutine converts the internal time and
date specification tmdate that is generated by the
localtime or gmtime clock structures of ctime (see
"ctime, localtime, gmtime, asctime, tzset") into a char-
acter string under the direction of format. The
resulting string is similar to the result of printf
format, and is placed in the memory location addressed by
str. It has a maximum length of len and terminates with
a NULL.
Many conversion specifications are the same as those used
by the date command. The interpretation of some conver-
sion specifications is affected by the values of environ-
ment variables for international character support (see
"environment").
The format parameter is a character string containing two
types of objects: plain characters that are simply placed
in the output string, and conversion specifications that
convert information from tmdate into readable form in the
output string. Each conversion specification is a
sequence of this form:
%[[-|width|[.precision|type
o A % (percent sign) introduces a conversion specifica-
tion.
o An optional decimal digit string specifies a minimum
field width. A converted value that has fewer char-
acters than the field width is padded with spaces to
the right. If the decimal digit string is preceded
by a minus sign, padding with spaces occurs to the
left of the converted value.
If no width is given, for numeric fields the appro-
priate default width is used with the field padded on
the left with zeros as required. For strings, the
output field is made exactly wide enough to contain
the string.
o An optional precision value gives the maximum number
of characters to be printed for the conversion spec-
ification. The precision value is a decimal digit
string preceded by a period. If the value to be
output is longer than the precision, it is truncated
on the right.
o The type of conversion is specified by one or two
conversion characters. The characters and their
meanings are:
m The month of the year is output as a number
between 01 and 12.
h The short month is output as a string estab-
lished by the environment variable NLSMONTH
("Jan", for example).
lh The long month is output as a string established
by the environment variable NLLMONTH ("January",
for example).
d The day of the month is output as a number
between 01 and 31.
j The Julian day of the year is output as a number
between 001 and 366.
w The day of the week is output as a number
between 0 and 6.
a The short day of the week is output as a string
according to the environment variable NLDAY
("Mon", for example).
la The long day of the week is output according to
the environment variable NLLDAY ("Monday", for
example).
y The year is output as a number between 00 and
99.
Y The year is output as a number between 0000 and
9999.
D The date is output in the format specified by
the environment variable NLDATE ("05/05/86", for
example).
lD The long date is output in the format specified
by the environment variable NLLDATE ("Jul 04,
1986", for example).
sD The short date is output in the format specified
by the (long date) environment variable NLLDATE,
but the year is omitted ("July 7", for example).
H The hour of the day is output as a number
between 00 and 23.
sH The hour of the day is output as a number
between 01 and 12.
M The minute is output as a number between 00 and
59.
S The second is output as a number between 00 and
59.
p The AM or PM indicator is output as a string
specified by environmental variable NLTMISC
("am", for example).
z The (standard or daylight-saving) time zone name
is output as a string from the environment vari-
able TZ ("CDT", for example).
r The time is output in the format specified by
the environment variable NLtime, but using a 12
hour clock ("7:07:50 pm", for example).
T The time is output in the format specified by
the environment variable NLtime ("19:07:50", for
example).
sT The time is output in the format specified by
the environment variable NLTIME, but omitting
the seconds ("19:07", for example).
n Only a newline character is output.
t Only a tab character is output.
x Nothing is output; this conversion specification
is used only as a delimiter.
% The % (percent) character is output.
Related Information
In this book: "NLtmtime," "printf, fprintf, sprintf,
NLprintf, NLfprintf, NLsprintf," and "environment."
The date and ctime commands in AIX Operating System Com-
mands Reference.
"Overview of International Character Support" in Managing
the AIX Operating System.