strftime.c
上传用户:shbosideng
上传日期:2013-05-04
资源大小:1555k
文件大小:10k
- /**
- *
- * strftime.c
- *
- * implements the ansi c function strftime()
- *
- * written 6 september 1989 by jim nutt
- * released into the public domain by jim nutt
- *
- * modified 21-Oct-89 by Rob Duff
- *
- * modified 08-Dec-04 by Tobi Oetiker (added %V)
- **/
- #include <stddef.h> /* for size_t */
- #include <stdarg.h> /* for va_arg */
- #include <time.h> /* for struct tm */
- #include "strftime.h"
- static char *aday[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
- static char *day[] = {
- "Sunday", "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday"
- };
- static char *amonth[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
- static char *month[] = {
- "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December"
- };
- char *tzname_[2] = {"CST", "CDT"}; /* Add your own defaults here */
- static char buf[26];
- static void strfmt(char *str, const char *fmt, ...);
- /**
- *
- * size_t strftime_(char *str,
- * size_t maxs,
- * const char *fmt,
- * const struct tm *t)
- *
- * this functions acts much like a sprintf for time/date output.
- * given a pointer to an output buffer, a format string and a
- * time, it copies the time to the output buffer formatted in
- * accordance with the format string. the parameters are used
- * as follows:
- *
- * str is a pointer to the output buffer, there should
- * be at least maxs characters available at the address
- * pointed to by str.
- *
- * maxs is the maximum number of characters to be copied
- * into the output buffer, included the ' ' terminator
- *
- * fmt is the format string. a percent sign (%) is used
- * to indicate that the following character is a special
- * format character. the following are valid format
- * characters:
- *
- * %A full weekday name (Monday)
- * %a abbreviated weekday name (Mon)
- * %B full month name (January)
- * %b abbreviated month name (Jan)
- * %c standard date and time representation
- * %d day-of-month (01-31)
- * %H hour (24 hour clock) (00-23)
- * %I hour (12 hour clock) (01-12)
- * %j day-of-year (001-366)
- * %M minute (00-59)
- * %m month (01-12)
- * %p local equivalent of AM or PM
- * %S second (00-59)
- * %U week-of-year, first day sunday (00-53)
- * %W week-of-year, first day monday (00-53)
- * %V ISO 8601 Week number
- * %w weekday (0-6, sunday is 0)
- * %X standard time representation
- * %x standard date representation
- * %Y year with century
- * %y year without century (00-99)
- * %Z timezone name
- * %% percent sign
- *
- * the standard date string is equivalent to:
- *
- * %a %b %d %Y
- *
- * the standard time string is equivalent to:
- *
- * %H:%M:%S
- *
- * the standard date and time string is equivalent to:
- *
- * %a %b %d %H:%M:%S %Y
- *
- * strftime_() returns the number of characters placed in the
- * buffer, not including the terminating