Print this page
11586 NAME field in man pages should match what's installed
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man3c/strftime.3c.man.txt
+++ new/usr/src/man/man3c/strftime.3c.man.txt
1 1 STRFTIME(3C) Standard C Library Functions STRFTIME(3C)
2 2
3 3
4 4
5 5 NAME
6 - strftime, strftime_l cftime, ascftime - convert date and time to string
6 + strftime, strftime_l, cftime, ascftime - convert date and time to
7 + string
7 8
8 9 SYNOPSIS
9 10 #include <time.h>
10 11
11 12 size_t strftime(char *restrict s, size_t maxsize,
12 13 const char *restrict format,
13 14 const struct tm *restrict timeptr);
14 15
15 16 size_t strftime_l(char *restrict s, size_t maxsize,
16 17 const char *restrict format,
17 18 const struct tm *restrict timeptr, locale_t loc);
18 19
19 20 int cftime(char *s, char *format, const time_t *clock);
20 21
21 22 int ascftime(char *s, const char *format,
22 23 const struct tm *timeptr);
23 24
24 25
25 26 DESCRIPTION
26 27 The strftime(), strftime_l(), ascftime(), and cftime() functions place
27 28 bytes into the array pointed to by s as controlled by the string
28 29 pointed to by format. The format string consists of zero or more
29 30 conversion specifications and ordinary characters. A conversion
30 31 specification consists of a '%' (percent) character and one or two
31 32 terminating conversion characters that determine the conversion
32 33 specification's behavior. All ordinary characters (including the
33 34 terminating null byte) are copied unchanged into the array pointed to
34 35 by s. If copying takes place between objects that overlap, the behavior
35 36 is undefined. For strftime(), no more than maxsize bytes are placed
36 37 into the array. The strftime_l() function behaves identically to
37 38 strftime() function, but instead of operating in the current locale, it
38 39 operates in the locale specified by loc.
39 40
40 41 If format is NULL, then the locale's default format is used. For
41 42 strftime() the default format is the same as %c; for cftime() and
42 43 ascftime() the default format is the same as %+. cftime() and
43 44 ascftime() first try to use the value of the environment variable
44 45 CFTIME, and if that is undefined or empty, the default format is used.
45 46
46 47 Each conversion specification is replaced by appropriate characters as
47 48 described in the following list. The appropriate characters are
48 49 determined by the LC_TIME category of the program's locale and by the
49 50 values contained in the structure pointed to by timeptr for strftime()
50 51 and ascftime(), and by the time represented by clock for cftime().
51 52
52 53 %%
53 54 Same as %.
54 55
55 56
56 57 %a
57 58 Locale's abbreviated weekday name.
58 59
59 60
60 61 %A
61 62 Locale's full weekday name.
62 63
63 64
64 65 %b
65 66 Locale's abbreviated month name.
66 67
67 68
68 69 %B
69 70 Locale's full month name.
70 71
71 72
72 73 %c
73 74 Locale's appropriate date and time representation. In the C
74 75 locale, this format is:
75 76
76 77 %a %b %e %H:%M:%S %Y
77 78
78 79 Other locales may have different locale-specific formats.
79 80
80 81
81 82 %C
82 83 Century number (the year divided by 100 and truncated to an
83 84 integer as a decimal number [01,99]).
84 85
85 86
86 87 %d
87 88 Day of month [01,31].
88 89
89 90
90 91 %D
91 92 Date as %m/%d/%y.
92 93
93 94
94 95 %e
95 96 Day of month [1,31]; single digits are preceded by a space.
96 97
97 98
98 99 %F
99 100 Equivalent to %Y-%m-%d (the ISO 8601:2000 standard date format).
100 101
101 102
102 103 %g
103 104 Week-based year within century [00,99].
104 105
105 106
106 107 %G
107 108 Week-based year, including the century [0000,9999].
108 109
109 110
110 111 %h
111 112 Locale's abbreviated month name.
112 113
113 114
114 115 %H
115 116 Hour (24-hour clock) [00,23].
116 117
117 118
118 119 %I
119 120 Hour (12-hour clock) [01,12].
120 121
121 122
122 123 %j
123 124 Day number of year [001,366].
124 125
125 126
126 127 %k
127 128 Hour (24-hour clock) [0,23]; single digits are preceded by a
128 129 space.
129 130
130 131
131 132 %l
132 133 Hour (12-hour clock) [1,12]; single digits are preceded by a
133 134 space.
134 135
135 136
136 137 %m
137 138 Month number [01,12].
138 139
139 140
140 141 %M
141 142 Minute [00,59].
142 143
143 144
144 145 %n
145 146 Insert a NEWLINE.
146 147
147 148
148 149 %p
149 150 Locale's equivalent of either a.m. or p.m.
150 151
151 152
152 153 %r
153 154 Appropriate time representation in 12-hour clock format with %p.
154 155
155 156
156 157 %R
157 158 Time as %H:%M.
158 159
159 160
160 161 %s
161 162 Seconds since 00:00:00 UTC, January 1, 1970.
162 163
163 164
164 165 %S
165 166 Seconds [00,60]; the range of values is [00,60] rather than
166 167 [00,59] to allow for the occasional leap second.
167 168
168 169
169 170 %t
170 171 Insert a TAB.
171 172
172 173
173 174 %T
174 175 Time as %H:%M:%S.
175 176
176 177
177 178 %u
178 179 Weekday as a decimal number [1,7], with 1 representing Monday.
179 180 See NOTES below.
180 181
181 182
182 183 %U
183 184 Week number of year as a decimal number [00,53], with Sunday as
184 185 the first day of week 1.
185 186
186 187
187 188 %v
188 189 Date as %e-%b-%Y.
189 190
190 191
191 192 %V
192 193 The ISO 8601 week number as a decimal number [01,53]. In the ISO
193 194 8601 week-based system, weeks begin on a Monday and week 1 of the
194 195 year is the week that includes both January 4th and the first
195 196 Thursday of the year. If the first Monday of January is the 2nd,
196 197 3rd, or 4th, the preceding days are part of the last week of the
197 198 preceding year. See NOTES below.
198 199
199 200
200 201 %w
201 202 Weekday as a decimal number [0,6], with 0 representing Sunday.
202 203
203 204
204 205 %W
205 206 Week number of year as a decimal number [00,53], with Monday as
206 207 the first day of week 1.
207 208
208 209
209 210 %x
210 211 Locale's appropriate date representation.
211 212
212 213
213 214 %X
214 215 Locale's appropriate time representation.
215 216
216 217
217 218 %y
218 219 Year within century [00,99].
219 220
220 221
221 222 %Y
222 223 Year, including the century (for example 1993).
223 224
224 225
225 226 %z
226 227 Replaced by offset from UTC in ISO 8601:2000 standard format
227 228 (+hhmm or -hhmm), or by no characters if no time zone is
228 229 determinable. For example, "-0430" means 4 hours 30 minutes
229 230 behind UTC (west of Greenwich). If tm_isdst is zero, the standard
230 231 time offset is used. If tm_isdst is greater than zero, the
231 232 daylight savings time offset if used. If tm_isdst is negative, no
232 233 characters are returned.
233 234
234 235
235 236 %Z
236 237 Time zone name or abbreviation, or no bytes if no time zone
237 238 information exists.
238 239
239 240
240 241 %+
241 242 Locale's date and time representation as produced by date(1).
242 243
243 244
244 245 If a conversion specification does not correspond to any of the above
245 246 or to any of the modified conversion specifications listed below, the
246 247 behavior is undefined and 0 is returned.
247 248
248 249 The difference between %U and %W (and also between modified conversion
249 250 specifications %OU and %OW) lies in which day is counted as the first
250 251 of the week. Week number 1 is the first week in January starting with a
251 252 Sunday for %U or a Monday for %W. Week number 0 contains those days
252 253 before the first Sunday or Monday in January for %U and %W,
253 254 respectively.
254 255
255 256 Modified Conversion Specifications
256 257 Some conversion specifications can be modified by the E and O modifiers
257 258 to indicate that an alternate format or specification should be used
258 259 rather than the one normally used by the unmodified conversion
259 260 specification. If the alternate format or specification does not exist
260 261 in the current locale, the behavior will be as if the unmodified
261 262 specification were used.
262 263
263 264 %Ec
264 265 Locale's alternate appropriate date and time representation.
265 266
266 267
267 268 %EC
268 269 Name of the base year (period) in the locale's alternate
269 270 representation.
270 271
271 272
272 273 %Eg
273 274 Offset from %EC of the week-based year in the locale's
274 275 alternative representation.
275 276
276 277
277 278 %EG
278 279 Full alternative representation of the week-based year.
279 280
280 281
281 282 %Ex
282 283 Locale's alternate date representation.
283 284
284 285
285 286 %EX
286 287 Locale's alternate time representation.
287 288
288 289
289 290 %Ey
290 291 Offset from %EC (year only) in the locale's alternate
291 292 representation.
292 293
293 294
294 295 %EY
295 296 Full alternate year representation.
296 297
297 298
298 299 %Od
299 300 Day of the month using the locale's alternate numeric symbols.
300 301
301 302
302 303 %Oe
303 304 Same as %Od.
304 305
305 306
306 307 %Og
307 308 Week-based year (offset from %C) in the locale's alternate
308 309 representation and using the locale's alternate numeric symbols.
309 310
310 311
311 312 %OH
312 313 Hour (24-hour clock) using the locale's alternate numeric
313 314 symbols.
314 315
315 316
316 317 %OI
317 318 Hour (12-hour clock) using the locale's alternate numeric
318 319 symbols.
319 320
320 321
321 322 %Om
322 323 Month using the locale's alternate numeric symbols.
323 324
324 325
325 326 %OM
326 327 Minutes using the locale's alternate numeric symbols.
327 328
328 329
329 330 %OS
330 331 Seconds using the locale's alternate numeric symbols.
331 332
332 333
333 334 %Ou
334 335 Weekday as a number in the locale's alternate numeric symbols.
335 336
336 337
337 338 %OU
338 339 Week number of the year (Sunday as the first day of the week)
339 340 using the locale's alternate numeric symbols.
340 341
341 342
342 343 %Ow
343 344 Number of the weekday (Sunday=0) using the locale's alternate
344 345 numeric symbols.
345 346
346 347
347 348 %OW
348 349 Week number of the year (Monday as the first day of the week)
349 350 using the locale's alternate numeric symbols.
350 351
351 352
352 353 %Oy
353 354 Year (offset from %C) in the locale's alternate representation
354 355 and using the locale's alternate numeric symbols.
355 356
356 357
357 358 Selecting the Output Language
358 359 These routines produce output that is formatted according to the
359 360 LC_TIME locale category. They use either the current locale, or in the
360 361 case of strftime_l(), the locale supplied by loc.
361 362
362 363 Time Zone
363 364 Local time zone information is used as though tzset(3C) were called.
364 365
365 366 RETURN VALUES
366 367 These functions return the number of characters placed into the array
367 368 pointed to by s, not including the terminating null character. If the
368 369 total number of resulting characters including the terminating null
369 370 character is more than maxsize, strftime() returns 0 and the contents
370 371 of the array are indeterminate.
371 372
372 373 EXAMPLES
373 374 Example 1 An example of the strftime() function.
374 375
375 376 The following example illustrates the use of strftime() for the POSIX
376 377 locale. It shows what the string in str would look like if the
377 378 structure pointed to by tmptr contains the values corresponding to
378 379 Thursday, August 28, 1986 at 12:44:36.
379 380
380 381 strftime(str, strsize, "%A %b %d %j", tmptr);
381 382
382 383 This results in str containing "Thursday Aug 28 240".
383 384
384 385 ATTRIBUTES
385 386 See attributes(5) for descriptions of the following attributes:
386 387
387 388 +--------------------+-----------------+
388 389 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
389 390 +--------------------+-----------------+
390 391 |CSI | Enabled |
391 392 +--------------------+-----------------+
392 393 |Interface Stability | See below. |
393 394 +--------------------+-----------------+
394 395 |MT-Level | MT-Safe |
395 396 +--------------------+-----------------+
396 397 |Standard | See below. |
397 398 +--------------------+-----------------+
398 399
399 400 The strftime() and strftime_l() functions are Standard. cftime() and
400 401 ascftime() functions are Committed.
401 402
402 403 For strftime() and strftime_l(), see standards(5).
403 404
404 405 SEE ALSO
405 406 date(1), ctime(3C), mktime(3C), newlocale(3C), setlocale(3C),
406 407 strptime(3C), tzset(3C), uselocale(3C), TIMEZONE(4), zoneinfo(4),
407 408 attributes(5), environ(5), standards(5)
408 409
409 410 NOTES
410 411 The conversion specification for %V was changed in the Solaris 7
411 412 release. This change was based on the public review draft of the ISO
412 413 C9x standard at that time. Previously, the specification stated that if
413 414 the week containing 1 January had fewer than four days in the new year,
414 415 it became week 53 of the previous year. The ISO C9x standard committee
415 416 subsequently recognized that that specification had been incorrect.
416 417
417 418 The conversion specifications for %g, %G, %Eg, %EG, and %Og were added
418 419 in the Solaris 7 release. This change was based on the public review
419 420 draft of the ISO C9x standard at that time. The %g and %G
420 421 specifications were adopted in the formal standard. The other two were
421 422 not, and should not be used in portable applications.
422 423
423 424 The conversion specification for %u was changed in the Solaris 8
424 425 release. This change was based on the XPG4 specification.
425 426
↓ open down ↓ |
409 lines elided |
↑ open up ↑ |
426 427 If using the %Z specifier and zoneinfo timezones and if the input date
427 428 is outside the range 20:45:52 UTC, December 13, 1901 to 03:14:07 UTC,
428 429 January 19, 2038, the timezone name may not be correct.
429 430
430 431 The conversion specification for %+ was added in illumos. It is not
431 432 part of any standard, although it is available on a number of other
432 433 platforms. Its use is discouraged for conforming applications.
433 434
434 435
435 436
436 - March 30, 2019 STRFTIME(3C)
437 + August 20, 2019 STRFTIME(3C)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX