home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / ansi / time / strftime.txh < prev    next >
Encoding:
Text File  |  1995-07-10  |  2.9 KB  |  164 lines

  1. @node strftime, time
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <time.h>
  6.  
  7. size_t strftime(char *buf, size_t n, const char *format, const struct tm *time);
  8. @end example
  9.  
  10. @subheading Description
  11.  
  12. This function formats the given @var{time} according to the given
  13. @var{format} and stores it in @var{buf}, not exceeding @var{n} bytes. 
  14.  
  15. The format string is like @code{printf} in that any character other than
  16. @code{%} is added to the output string, and for each character following
  17. a @code{%} a pattern is added to the string as follows, with the
  18. examples as if the time was Friday, October 1, 1993, at 03:30:34 PM EDT:
  19.  
  20. @table @code
  21.  
  22. @item %A
  23.  
  24. The full weekday name (@code{Friday})
  25.  
  26. @item %a
  27.  
  28. The abbreviated weekday name (@code{Fri})
  29.  
  30. @item %B
  31.  
  32. The full month name (@code{October})
  33.  
  34. @item %b
  35. @itemx %h
  36.  
  37. The abbreviated month name (@code{Oct})
  38.  
  39. @item %C
  40.  
  41. Short for @code{%a %b %e %H:%M:%S %Y} (@code{Fri Oct  1 15:30:34 1993})
  42.  
  43. @item %c
  44.  
  45. Short for @code{%m/%d/%y %H:%M:%S} (@code{10/01/93 15:30:34})
  46.  
  47. @item %e
  48.  
  49. The day of the month, blank padded to two characters (@code{ 2})
  50.  
  51. @item %D
  52.  
  53. Short for @code{%m/%d/%y} (@code{10/01/93})
  54.  
  55. @item %d
  56.  
  57. The day of the month, zero padded to two characters (@code{02})
  58.  
  59. @item %H
  60.  
  61. The hour (0-24), zero padded to two characters (@code{15})
  62.  
  63. @item %I
  64.  
  65. The hour (1-12), zero padded to two characters (@code{03})
  66.  
  67. @item %j
  68.  
  69. The Julian day, zero padded to three characters (@code{275})
  70.  
  71. @item %k
  72.  
  73. The hour (0-24), space padded to two characters (@code{15})
  74.  
  75. @item %l
  76.  
  77. The hour (1-12), space padded to two characters(@code{ 3})
  78.  
  79. @item %M
  80.  
  81. The minutes, zero padded to two characters (@code{30})
  82.  
  83. @item %m
  84.  
  85. The month (1-12), zero padded to two characters (@code{10})
  86.  
  87. @item %n
  88.  
  89. A newline (@code{\n})
  90.  
  91. @item %p
  92.  
  93. AM or PM (@code{PM})
  94.  
  95. @item %R
  96.  
  97. Short for @code{%H:%M} (@code{15:30})
  98.  
  99. @item %r
  100.  
  101. Short for @code{%I:%M:%S %p} (@code{03:30:35 PM})
  102.  
  103. @item %S
  104.  
  105. The seconds, zero padded to two characters (@code{35})
  106.  
  107. @item %T
  108. @itemx %X
  109.  
  110. Short for @code{%H:%M:%S} (@code{15:30:35})
  111.  
  112. @item %t
  113.  
  114. A tab (@code{\t})
  115.  
  116. @item %U
  117.  
  118. The week of the year, with the first week defined by the first Sunday of
  119. the year, zero padded to two characters (@code{39})
  120.  
  121. @item %W
  122.  
  123. The week of the year, with the first week defined by the first Monday of
  124. the year, zero padded to two characters (@code{39})
  125.  
  126. @item %w
  127.  
  128. The day of the week (0-6) (@code{5})
  129.  
  130. @item %x
  131.  
  132. Short for @code{%m/%d/%y} (@code{10/01/93})
  133.  
  134. @item %y
  135.  
  136. The year (00-99) of the century (@code{93})
  137.  
  138. @item %Y
  139.  
  140. The year, zero padded to four digits (@code{1993})
  141.  
  142. @item %Z
  143.  
  144. The timezone abbreviation (@code{EDT})
  145.  
  146. @item %%
  147.  
  148. A percent symbol (@code{%})
  149.  
  150. @end table
  151.  
  152. @subheading Return Value
  153.  
  154. The number of characters stored.
  155.  
  156. @subheading Example
  157.  
  158. @example
  159. struct tm t;
  160. char buf[100];
  161. strftime(buf, 100, "%B %d, %Y", &t);
  162. @end example
  163.  
  164.