1 '\" te
2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\" This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH STRFTIME 3C "Sep 5, 2006"
13 .SH NAME
14 strftime, cftime, ascftime \- convert date and time to string
15 .SH SYNOPSIS
16 .LP
17 .nf
18 #include <time.h>
19
20 \fBsize_t\fR \fBstrftime\fR(\fBchar *restrict\fR \fIs\fR, \fBsize_t\fR \fImaxsize\fR,
21 \fBconst char *restrict\fR \fIformat\fR,
22 \fBconst struct tm *restrict\fR \fItimeptr\fR);
23 .fi
24
25 .LP
26 .nf
27 \fBint\fR \fBcftime\fR(\fBchar *\fR\fIs\fR, \fBchar *\fR\fIformat\fR, \fBconst time_t *\fR\fIclock\fR);
28 .fi
29
30 .LP
31 .nf
32 \fBint\fR \fBascftime\fR(\fBchar *\fR\fIs\fR, \fBconst char *\fR\fIformat\fR,
33 \fBconst struct tm *\fR\fItimeptr\fR);
34 .fi
35
36 .SH DESCRIPTION
37 .sp
38 .LP
39 The \fBstrftime()\fR, \fBascftime()\fR, and \fBcftime()\fR functions place
40 bytes into the array pointed to by \fIs\fR as controlled by the string pointed
41 to by \fIformat\fR. The \fIformat\fR string consists of zero or more conversion
42 specifications and ordinary characters. A conversion specification consists of
43 a '\fB%\fR' (percent) character and one or two terminating conversion
44 characters that determine the conversion specification's behavior. All
45 ordinary characters (including the terminating null byte) are copied unchanged
46 into the array pointed to by \fIs\fR. If copying takes place between objects
47 that overlap, the behavior is undefined. For \fBstrftime()\fR, no more than
48 \fImaxsize\fR bytes are placed into the array.
49 .sp
50 .LP
51 If \fIformat\fR is \fB(char *)0\fR, then the locale's default format is used.
52 For \fBstrftime()\fR the default format is the same as \fB%c\fR; for
53 \fBcftime()\fR and \fBascftime()\fR the default format is the same as \fB%C\fR.
54 \fBcftime()\fR and \fBascftime()\fR first try to use the value of the
55 environment variable \fBCFTIME\fR, and if that is undefined or empty, the
56 default format is used.
57 .sp
58 .LP
59 Each conversion specification is replaced by appropriate characters as
60 described in the following list. The appropriate characters are determined by
61 the \fBLC_TIME\fR category of the program's locale and by the values contained
62 in the structure pointed to by \fItimeptr\fR for \fBstrftime()\fR and
63 \fBascftime()\fR, and by the time represented by \fIclock\fR for
64 \fBcftime()\fR.
65 .sp
66 .ne 2
67 .na
68 \fB\fB%%\fR\fR
69 .ad
70 .RS 6n
71 Same as \fB%\fR.
72 .RE
73
90 .RE
91
92 .sp
93 .ne 2
94 .na
95 \fB\fB%b\fR\fR
96 .ad
97 .RS 6n
98 Locale's abbreviated month name.
99 .RE
100
101 .sp
102 .ne 2
103 .na
104 \fB\fB%B\fR\fR
105 .ad
106 .RS 6n
107 Locale's full month name.
108 .RE
109
110 .SS "Default"
111 .sp
112 .ne 2
113 .na
114 \fB\fB%c\fR\fR
115 .ad
116 .RS 6n
117 Locale's appropriate date and time represented as:
118 .sp
119 .in +2
120 .nf
121 %a %b %d %H:%M:%S %Y
122 .fi
123 .in -2
124
125 This is the default behavior as well as standard-conforming behavior for
126 standards first supported by releases prior to Solaris 2.4. See
127 \fBstandards\fR(5).
128 .RE
129
130 .SS "Standard conforming"
131 .sp
132 .ne 2
133 .na
134 \fB\fB%c\fR\fR
135 .ad
136 .RS 6n
137 Locale's appropriate date and time represented as:
138 .sp
139 .in +2
140 .nf
141 %a %b %e %H:%M:%S %Y
142 .fi
143 .in -2
144
145 This is standard-conforming behavior for standards first supported by Solaris
146 2.4 through Solaris 10.
147 .RE
148
149 .SS "Default"
150 .sp
151 .ne 2
152 .na
153 \fB\fB%C\fR\fR
154 .ad
155 .RS 6n
156 Locale's date and time representation as produced by \fBdate\fR(1).
157 .sp
158 This is the default behavior as well as standard-conforming behavior for
159 standards first supported by releases prior to Solaris 2.4.
160 .RE
161
162 .SS "Standard conforming"
163 .sp
164 .ne 2
165 .na
166 \fB\fB%C\fR\fR
167 .ad
168 .RS 6n
169 Century number (the year divided by 100 and truncated to an integer as a
170 decimal number [01,99]).
171 .sp
172 This is standard-conforming behavior for standards first supported by Solaris
173 2.4 through Solaris 10.
174 .RE
175
176 .sp
177 .ne 2
178 .na
179 \fB\fB%d\fR\fR
180 .ad
181 .RS 6n
182 Day of month [01,31].
183 .RE
184
185 .sp
186 .ne 2
187 .na
188 \fB\fB%D\fR\fR
189 .ad
190 .RS 6n
191 Date as \fB%m\fR/\fB%d\fR/\fB%y\fR.
192 .RE
193
322 .ne 2
323 .na
324 \fB\fB%r\fR\fR
325 .ad
326 .RS 6n
327 Appropriate time representation in 12-hour clock format with \fB%p\fR.
328 .RE
329
330 .sp
331 .ne 2
332 .na
333 \fB\fB%R\fR\fR
334 .ad
335 .RS 6n
336 Time as \fB%H\fR:\fB%M\fR.
337 .RE
338
339 .sp
340 .ne 2
341 .na
342 \fB\fB%S\fR\fR
343 .ad
344 .RS 6n
345 Seconds [00,60]; the range of values is [00,60] rather than [00,59] to allow
346 for the occasional leap second.
347 .RE
348
349 .sp
350 .ne 2
351 .na
352 \fB\fB%t\fR\fR
353 .ad
354 .RS 6n
355 Insert a TAB.
356 .RE
357
358 .sp
359 .ne 2
360 .na
361 \fB\fB%T\fR\fR
370 \fB\fB%u\fR\fR
371 .ad
372 .RS 6n
373 Weekday as a decimal number [1,7], with 1 representing Monday. See \fBNOTES\fR
374 below.
375 .RE
376
377 .sp
378 .ne 2
379 .na
380 \fB\fB%U\fR\fR
381 .ad
382 .RS 6n
383 Week number of year as a decimal number [00,53], with Sunday as the first day
384 of week 1.
385 .RE
386
387 .sp
388 .ne 2
389 .na
390 \fB\fB%V\fR\fR
391 .ad
392 .RS 6n
393 The ISO 8601 week number as a decimal number [01,53]. In the ISO 8601
394 week-based system, weeks begin on a Monday and week 1 of the year is the week
395 that includes both January 4th and the first Thursday of the year. If the
396 first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of
397 the last week of the preceding year. See \fBNOTES\fR below.
398 .RE
399
400 .sp
401 .ne 2
402 .na
403 \fB\fB%w\fR\fR
404 .ad
405 .RS 6n
406 Weekday as a decimal number [0,6], with 0 representing Sunday.
407 .RE
408
409 .sp
459 .ad
460 .RS 6n
461 Replaced by offset from UTC in ISO 8601:2000 standard format (\fB+hhmm\fR or
462 \fB-hhmm\fR), or by no characters if no time zone is determinable. For example,
463 "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich). If
464 \fBtm_isdst\fR is zero, the standard time offset is used. If \fBtm_isdst\fR is
465 greater than zero, the daylight savings time offset if used. If \fBtm_isdst\fR
466 is negative, no characters are returned.
467 .RE
468
469 .sp
470 .ne 2
471 .na
472 \fB\fB%Z\fR\fR
473 .ad
474 .RS 6n
475 Time zone name or abbreviation, or no bytes if no time zone information exists.
476 .RE
477
478 .sp
479 .LP
480 If a conversion specification does not correspond to any of the above or to any
481 of the modified conversion specifications listed below, the behavior is
482 undefined and \fB0\fR is returned.
483 .sp
484 .LP
485 The difference between \fB%U\fR and \fB%W\fR (and also between modified
486 conversion specifications \fB%OU\fR and \fB%OW\fR) lies in which day is counted
487 as the first of the week. Week number 1 is the first week in January starting
488 with a Sunday for \fB%U\fR or a Monday for \fB%W\fR. Week number 0 contains
489 those days before the first Sunday or Monday in January for \fB%U\fR and
490 \fB%W\fR, respectively.
491 .SS "Modified Conversion Specifications"
492 .sp
493 .LP
494 Some conversion specifications can be modified by the \fBE\fR and \fBO\fR
495 modifiers to indicate that an alternate format or specification should be used
496 rather than the one normally used by the unmodified conversion specification.
497 If the alternate format or specification does not exist in the current locale,
498 the behavior will be as if the unmodified specification were used.
771 January had fewer than four days in the new year, it became week 53 of the
772 previous year. The ISO C9x standard committee subsequently recognized that that
773 specification had been incorrect.
774 .sp
775 .LP
776 The conversion specifications for \fB%g\fR, \fB%G\fR, \fB%Eg\fR, \fB%EG\fR, and
777 \fB%Og\fR were added in the Solaris 7 release. This change was based on the
778 public review draft of the ISO C9x standard at that time. These specifications
779 are evolving. If the ISO C9x standard is finalized with a different
780 conclusion, these specifications will change to conform to the ISO C9x standard
781 decision.
782 .sp
783 .LP
784 The conversion specification for \fB%u\fR was changed in the Solaris 8 release.
785 This change was based on the XPG4 specification.
786 .sp
787 .LP
788 If using the \fB%Z\fR specifier and \fBzoneinfo\fR timezones and if the input
789 date is outside the range 20:45:52 UTC, December 13, 1901 to 03:14:07 UTC,
790 January 19, 2038, the timezone name may not be correct.
|
1 '\" te
2 .\" Copyright (c) 2014 Gary Mills
3 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
4 .\" Copyright 1989 AT&T
5 .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
7 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 .\" This notice shall appear on any product containing this material.
10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .TH STRFTIME 3C "Jan 3, 2014"
14 .SH NAME
15 strftime, cftime, ascftime \- convert date and time to string
16 .SH SYNOPSIS
17 .LP
18 .nf
19 #include <time.h>
20
21 \fBsize_t\fR \fBstrftime\fR(\fBchar *restrict\fR \fIs\fR, \fBsize_t\fR \fImaxsize\fR,
22 \fBconst char *restrict\fR \fIformat\fR,
23 \fBconst struct tm *restrict\fR \fItimeptr\fR);
24 .fi
25
26 .LP
27 .nf
28 \fBint\fR \fBcftime\fR(\fBchar *\fR\fIs\fR, \fBchar *\fR\fIformat\fR, \fBconst time_t *\fR\fIclock\fR);
29 .fi
30
31 .LP
32 .nf
33 \fBint\fR \fBascftime\fR(\fBchar *\fR\fIs\fR, \fBconst char *\fR\fIformat\fR,
34 \fBconst struct tm *\fR\fItimeptr\fR);
35 .fi
36
37 .SH DESCRIPTION
38 .sp
39 .LP
40 The \fBstrftime()\fR, \fBascftime()\fR, and \fBcftime()\fR functions place
41 bytes into the array pointed to by \fIs\fR as controlled by the string pointed
42 to by \fIformat\fR. The \fIformat\fR string consists of zero or more conversion
43 specifications and ordinary characters. A conversion specification consists of
44 a '\fB%\fR' (percent) character and one or two terminating conversion
45 characters that determine the conversion specification's behavior. All
46 ordinary characters (including the terminating null byte) are copied unchanged
47 into the array pointed to by \fIs\fR. If copying takes place between objects
48 that overlap, the behavior is undefined. For \fBstrftime()\fR, no more than
49 \fImaxsize\fR bytes are placed into the array.
50 .sp
51 .LP
52 If \fIformat\fR is \fB(char *)0\fR, then the locale's default format is used.
53 For \fBstrftime()\fR the default format is the same as \fB%c\fR; for
54 \fBcftime()\fR and \fBascftime()\fR the default format is the same as \fB%+\fR.
55 \fBcftime()\fR and \fBascftime()\fR first try to use the value of the
56 environment variable \fBCFTIME\fR, and if that is undefined or empty, the
57 default format is used.
58 .sp
59 .LP
60 Each conversion specification is replaced by appropriate characters as
61 described in the following list. The appropriate characters are determined by
62 the \fBLC_TIME\fR category of the program's locale and by the values contained
63 in the structure pointed to by \fItimeptr\fR for \fBstrftime()\fR and
64 \fBascftime()\fR, and by the time represented by \fIclock\fR for
65 \fBcftime()\fR.
66 .sp
67 .ne 2
68 .na
69 \fB\fB%%\fR\fR
70 .ad
71 .RS 6n
72 Same as \fB%\fR.
73 .RE
74
91 .RE
92
93 .sp
94 .ne 2
95 .na
96 \fB\fB%b\fR\fR
97 .ad
98 .RS 6n
99 Locale's abbreviated month name.
100 .RE
101
102 .sp
103 .ne 2
104 .na
105 \fB\fB%B\fR\fR
106 .ad
107 .RS 6n
108 Locale's full month name.
109 .RE
110
111 .sp
112 .ne 2
113 .na
114 \fB\fB%c\fR\fR
115 .ad
116 .RS 6n
117 Locale's appropriate date and time representation.
118 In the C locale, this format is:
119 .sp
120 .in +2
121 .nf
122 %a %b %e %H:%M:%S %Y
123 .fi
124 .in -2
125 .sp
126 Other locales may have different locale-specific formats.
127 .RE
128
129 .sp
130 .ne 2
131 .na
132 \fB\fB%C\fR\fR
133 .ad
134 .RS 6n
135 Century number (the year divided by 100 and truncated to an integer as a
136 decimal number [01,99]).
137 .RE
138
139 .sp
140 .ne 2
141 .na
142 \fB\fB%d\fR\fR
143 .ad
144 .RS 6n
145 Day of month [01,31].
146 .RE
147
148 .sp
149 .ne 2
150 .na
151 \fB\fB%D\fR\fR
152 .ad
153 .RS 6n
154 Date as \fB%m\fR/\fB%d\fR/\fB%y\fR.
155 .RE
156
285 .ne 2
286 .na
287 \fB\fB%r\fR\fR
288 .ad
289 .RS 6n
290 Appropriate time representation in 12-hour clock format with \fB%p\fR.
291 .RE
292
293 .sp
294 .ne 2
295 .na
296 \fB\fB%R\fR\fR
297 .ad
298 .RS 6n
299 Time as \fB%H\fR:\fB%M\fR.
300 .RE
301
302 .sp
303 .ne 2
304 .na
305 \fB\fB%s\fR\fR
306 .ad
307 .RS 6n
308 Seconds since 00:00:00 UTC, January 1, 1970.
309 .RE
310
311 .sp
312 .ne 2
313 .na
314 \fB\fB%S\fR\fR
315 .ad
316 .RS 6n
317 Seconds [00,60]; the range of values is [00,60] rather than [00,59] to allow
318 for the occasional leap second.
319 .RE
320
321 .sp
322 .ne 2
323 .na
324 \fB\fB%t\fR\fR
325 .ad
326 .RS 6n
327 Insert a TAB.
328 .RE
329
330 .sp
331 .ne 2
332 .na
333 \fB\fB%T\fR\fR
342 \fB\fB%u\fR\fR
343 .ad
344 .RS 6n
345 Weekday as a decimal number [1,7], with 1 representing Monday. See \fBNOTES\fR
346 below.
347 .RE
348
349 .sp
350 .ne 2
351 .na
352 \fB\fB%U\fR\fR
353 .ad
354 .RS 6n
355 Week number of year as a decimal number [00,53], with Sunday as the first day
356 of week 1.
357 .RE
358
359 .sp
360 .ne 2
361 .na
362 \fB\fB%v\fR\fR
363 .ad
364 .RS 6n
365 Date as \fB%e\fR-\fB%b\fR-\fB%Y\fR.
366 .RE
367
368 .sp
369 .ne 2
370 .na
371 \fB\fB%V\fR\fR
372 .ad
373 .RS 6n
374 The ISO 8601 week number as a decimal number [01,53]. In the ISO 8601
375 week-based system, weeks begin on a Monday and week 1 of the year is the week
376 that includes both January 4th and the first Thursday of the year. If the
377 first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of
378 the last week of the preceding year. See \fBNOTES\fR below.
379 .RE
380
381 .sp
382 .ne 2
383 .na
384 \fB\fB%w\fR\fR
385 .ad
386 .RS 6n
387 Weekday as a decimal number [0,6], with 0 representing Sunday.
388 .RE
389
390 .sp
440 .ad
441 .RS 6n
442 Replaced by offset from UTC in ISO 8601:2000 standard format (\fB+hhmm\fR or
443 \fB-hhmm\fR), or by no characters if no time zone is determinable. For example,
444 "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich). If
445 \fBtm_isdst\fR is zero, the standard time offset is used. If \fBtm_isdst\fR is
446 greater than zero, the daylight savings time offset if used. If \fBtm_isdst\fR
447 is negative, no characters are returned.
448 .RE
449
450 .sp
451 .ne 2
452 .na
453 \fB\fB%Z\fR\fR
454 .ad
455 .RS 6n
456 Time zone name or abbreviation, or no bytes if no time zone information exists.
457 .RE
458
459 .sp
460 .ne 2
461 .na
462 \fB\fB%+\fR\fR
463 .ad
464 .RS 6n
465 Locale's date and time representation as produced by \fBdate\fR(1).
466 .RE
467
468 .sp
469 .LP
470 If a conversion specification does not correspond to any of the above or to any
471 of the modified conversion specifications listed below, the behavior is
472 undefined and \fB0\fR is returned.
473 .sp
474 .LP
475 The difference between \fB%U\fR and \fB%W\fR (and also between modified
476 conversion specifications \fB%OU\fR and \fB%OW\fR) lies in which day is counted
477 as the first of the week. Week number 1 is the first week in January starting
478 with a Sunday for \fB%U\fR or a Monday for \fB%W\fR. Week number 0 contains
479 those days before the first Sunday or Monday in January for \fB%U\fR and
480 \fB%W\fR, respectively.
481 .SS "Modified Conversion Specifications"
482 .sp
483 .LP
484 Some conversion specifications can be modified by the \fBE\fR and \fBO\fR
485 modifiers to indicate that an alternate format or specification should be used
486 rather than the one normally used by the unmodified conversion specification.
487 If the alternate format or specification does not exist in the current locale,
488 the behavior will be as if the unmodified specification were used.
761 January had fewer than four days in the new year, it became week 53 of the
762 previous year. The ISO C9x standard committee subsequently recognized that that
763 specification had been incorrect.
764 .sp
765 .LP
766 The conversion specifications for \fB%g\fR, \fB%G\fR, \fB%Eg\fR, \fB%EG\fR, and
767 \fB%Og\fR were added in the Solaris 7 release. This change was based on the
768 public review draft of the ISO C9x standard at that time. These specifications
769 are evolving. If the ISO C9x standard is finalized with a different
770 conclusion, these specifications will change to conform to the ISO C9x standard
771 decision.
772 .sp
773 .LP
774 The conversion specification for \fB%u\fR was changed in the Solaris 8 release.
775 This change was based on the XPG4 specification.
776 .sp
777 .LP
778 If using the \fB%Z\fR specifier and \fBzoneinfo\fR timezones and if the input
779 date is outside the range 20:45:52 UTC, December 13, 1901 to 03:14:07 UTC,
780 January 19, 2038, the timezone name may not be correct.
781 .sp
782 .LP
783 The conversion specification for \fB%+\fR was added in illumos.
784 It is not part of any standard, although it is available on a number
785 of other platforms.
786 Its use is discouraged for conforming applications.
|