⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strftime.3

📁 早期freebsd实现
💻 3
字号:
.TH STRFTIME 3.SH NAMEstrftime \- generate formatted time information.SH SYNOPSIS.ft B.nf#include <sys/types.h>#include <time.h>.spsize_t strftime(char *s, size_t maxsize, const char *format,	const struct tm *timeptr);.SH DESCRIPTIONThe following description is transcribed verbatim from the December 7, 1988draft standard for ANSI C.This draft is essentially identical in technical contentto the final version of the standard..LPThe.B strftimefunction places characters into the array pointed to by.B sas controlled by the string pointed to by.BR format .The format shall be a multibyte character sequence, beginning and ending inits initial shift state.The.B formatstring consists of zero or more conversion specifiers and ordinarymultibyte characters.  A conversion specifier consists of a.B %character followed by a character that determines the behavior of theconversion specifier.All ordinary multibyte characters (including the terminating nullcharacter) are copied unchanged into the array.If copying takes place between objects that overlap the behavior is undefined.No more than.B maxsizecharacters are placed into the array.Each conversion specifier is replaced by appropriate characters as describedin the following list.The appropriate characters are determined by the.B LC_TIMEcategory of the current locale and by the values contained in thestructure pointed to by.BR timeptr ..TP.B %ais replaced by the locale's abbreviated weekday name..TP.B %Ais replaced by the locale's full weekday name..TP.B %bis replaced by the locale's abbreviated month name..TP.B %Bis replaced by the locale's full month name..TP.B %cis replaced by the locale's appropriate date and time representation..TP.B %dis replaced by the day of the month as a decimal number.RB ( 01 - 31 )..TP.B %His replaced by the hour (24-hour clock) as a decimal number.RB ( 00 - 23 )..TP.B %Iis replaced by the hour (12-hour clock) as a decimal number.RB ( 01 - 12 )..TP.B %jis replaced by the day of the year as a decimal number.RB ( 001 - 366 )..TP.B %mis replaced by the month as a decimal number.RB ( 01 - 12 )..TP.B %Mis replaced by the minute as a decimal number.RB ( 00 - 59 )..TP.B %pis replaced by the locale's equivalent of the AM/PM designations associatedwith a 12-hour clock..TP.B %Sis replaced by the second as a decimal number.RB ( 00 - 61 )..TP.B %Uis replaced by the week number of the year (the first Sunday as the firstday of week 1) as a decimal number.RB ( 00 - 53 )..TP.B %wis replaced by the weekday as a decimal number.RB [ "0 " (Sunday)- 6 ]..TP.B %Wis replaced by the week number of the year (the first Monday as the firstday of week 1) as a decimal number.RB ( 00 - 53 )..TP.B %xis replaced by the locale's appropriate date representation..TP.B %Xis replaced by the locale's appropriate time representation..TP.B %yis replaced by the year without century as a decimal number.RB ( 00 - 99 )..TP.B %Yis replaced by the year with century as a decimal number..TP.B %Zis replaced by the time zone name or abbreviation, or by no characters ifno time zone is determinable..TP.B %%is replaced by.BR % ..LPIf a conversion specifier is not one of the above, the behavior isundefined..SH RETURNSIf the total number of resulting characters including the terminating nullcharacter is not more than.BR maxsize ,the.B strftimefunction returns the number of characters placed into the array pointed toby.B snot including the terminating null character.Otherwise, zero is returned and the contents of the array are indeterminate..SH NON-ANSI EXTENSIONSIf.B SYSV_EXTis defined when the routine is compiled, then the following additionalconversions will be available.These are borrowed from the System V.IR cftime (3)and.IR ascftime (3)routines..TP.B %Dis equivalent to specifying.BR %m/%d/%y ..TP.B %eis replaced by the day of the month,padded with a blank if it is only one digit..TP.B %his equivalent to.BR %b ,above..TP.B %nis replaced with a newline character (\s-1ASCII LF\s+1)..TP.B %ris equivalent to specifying.BR "%I:%M:%S %p" ..TP.B %Ris equivalent to specifying.BR %H:%M ..TP.B %Tis equivalent to specifying.BR %H:%M:%S ..TP.B %tis replaced with a \s-1TAB\s+1 character..PPIf.B SUNOS_EXTis defined when the routine is compiled, then the following additionalconversions will be available.These are borrowed from the SunOS version of.IR strftime ..TP.B %kis replaced by the hour (24-hour clock) as a decimal number.RB ( 0 - 23 ).Single digit numbers are padded with a blank..TP.B %lis replaced by the hour (12-hour clock) as a decimal number.RB ( 1 - 12 ).Single digit numbers are padded with a blank..SH POSIX 1003.2 EXTENSIONSIf.B POSIX2_DATEis defined, then all of the conversions available with.B SYSV_EXTand.B SUNOS_EXTare available, as well as thefollowing additional conversions:.TP.B %CThe century, as a number between 00 and 99..TP.B %uis replaced by the weekday as a decimal number.RB [ "1 " (Monday)- 7 ]..TP.B %Vis replaced by the week number of the year (the first Monday as the firstday of week 1) as a decimal number.RB ( 01 - 53 ).The method for determining the week number is as specified by ISO 8601(to wit: if the week containing January 1 has four or more days in thenew year, then it is week 1, otherwise it is week 53 of the previous yearand the next week is week 1)..LPThe text of the POSIX standard for the.I dateutility describes.B %Uand.B %Wthis way:.TP.B %Uis replaced by the week number of the year (the first Sunday as the firstday of week 1) as a decimal number.RB ( 00 - 53 ).All days in a new year preceding the first Sunday are considered to bein week 0..TP.B %Wis replaced by the week number of the year (the first Monday as the firstday of week 1) as a decimal number.RB ( 00 - 53 ).All days in a new year preceding the first Sunday are considered to bein week 0.(Note: this last statement is quoted verbatim from the POSIX standard.It probably means to say ``all days in a new year preceding the first.I Mondayare considered to be in week 0.'').LPIn addition, the alternate representations.BR %Ec ,.BR %EC ,.BR %Ex ,.BR %Ey ,.BR %EY ,.BR %Od ,.BR %Oe ,.BR %OH ,.BR %OI ,.BR %Om ,.BR %OM ,.BR %OS ,.BR %Ou ,.BR %OU ,.BR %OV ,.BR %Ow ,.BR %OW ,and.B %Oyare recognized, but their normal representations are used..SH VMS EXTENSIONSIf.B VMS_EXTis defined, then the following additional conversion is available:.TP.B %vThe date in VMS format (e.g. 20-JUN-1991)..SH SEE ALSO.IR time (2),.IR ctime (3),.IR localtime (3),.IR tzset (3).SH BUGSThis version does not handle multibyte characters or pay attention to thesetting of the.B LC_TIMEenvironment variable..LPIt is not clear what is ``appropriate'' for the C locale; the valuesreturned are a best guess on the author's part..SH CAVEATSThe pre-processor symbol.B POSIX_SEMANTICSis automatically defined, which forces the code to call.IR tzset (3)whenever the.B TZenvironment variable has changed.If this routine will be used in an application that will not be changing.BR TZ ,then there may be some performance improvements by not defining.BR POSIX_SEMANTICS ..SH AUTHOR.nfArnold Robbins.spINTERNET: arnold@skeeve.atl.ga.usUUCP:     emory!skeeve!arnoldPhone:    +1 404 248 9324.fi.SH ACKNOWLEDGEMENTSThanks to Geoff Clare <gwc@root.co.uk> for helping debug earlierversions of this routine, and for advice about POSIX semantics.Additional thanks to Arthur David Olsen <ado@elsie.nci.nih.gov>for some code improvements.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -