strftime. McGraw-Hill The Complete Reference Fourth Edition
Annonce
Annonce
C h a p t e r 2 8 : T i m e , D a t e , a n d L o c a l i z a t i o n F u n c t i o n s
753
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
LC_ALL
refers to all localization categories. LC_COLLATE affects the operation of the strcoll( ) function. LC_CTYPE alters the way the character functions work.
LC_MONETARY
determines the monetary format. LC_NUMERIC changes the decimal-point character for formatted input/output functions. Finally, LC_TIME determines the behavior of the strftime( ) function.
The setlocale( ) function returns a pointer to a string associated with the type parameter.
Related functions are localeconv( ), time( ), strcoll( ), and strftime( ).
strftime
#include <ctime> size_t strftime(char * str, size_t maxsize, const char *fmt, const struct tm * time);
The strftime( ) function places time and date information, along with other information, into the string pointed to by str according to the format commands found in the string pointed to by fmt and using the broken-down time time. A maximum of
maxsize characters will be placed into str.
The strftime( ) function works a little like sprintf( ) in that it recognizes a set of format commands that begin with the percent sign (%) and places its formatted output into a string. The format commands are used to specify the exact way various time and date information is represented in str. Any other characters found in the format string are placed into str unchanged. The time and date displayed are in local time. The format commands are shown in the table below. Notice that many of the commands are case sensitive.
The strftime( ) function returns the number of characters placed in the string pointed to by str or zero if an error occurs.
Command
%a
%A
Replaced By
Abbreviated weekday name
Full weekday name
Download
Annonce