File: strftime.3

package info (click to toggle)
manpages-ja 0.5.0.0.20080615-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,508 kB
  • ctags: 1
  • sloc: sh: 13,690; perl: 157; makefile: 114
file content (478 lines) | stat: -rw-r--r-- 11,443 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" References consulted:
.\"     Linux libc source code
.\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\"     386BSD man pages
.\"     GNU texinfo documentation on glibc date/time functions.
.\" Modified Sat Jul 24 18:03:44 1993 by Rik Faith (faith@cs.unc.edu)
.\" Applied fix by Wolfgang Franke, aeb, 961011
.\" Corrected return value, aeb, 970307
.\" Added Single Unix Spec conversions and %z, aeb/esr, 990329.
.\" 2005-11-22 mtk, added Glibc Notes covering optional 'flag' and
.\"           'width' components of conversion specifications.
.\"
.\" Japanese Version Copyright (c) 2000 HANATAKA Shinya
.\"         all rights reserved.
.\" Translated 2000-10-10, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 2002-01-09, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2002-01-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-02-26, Akihiro MOTOKI
.\" Updated 2005-04-17, Akihiro MOTOKI
.\" Updated 2005-12-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.16
.\"
.\"WORD:	conversion specifier	Ѵʸ
.\"WORD:	conversion specification	Ѵ
.\"WORD:	modifier		
.\"WORD:	broken-down time	̤()
.\"WORD:	Single Unix Specification	 Unix 
.\"
.TH STRFTIME 3  2005-11-23 "GNU" "Linux Programmer's Manual"
.SH ̾
strftime \- դӻʸؤѴ
.SH 
.nf
.B #include <time.h>
.sp
.BI "size_t strftime(char *" s ", size_t " max ", const char *" format ,
.BI "                const struct tm *" tm );
.fi
.SH 
.BR strftime ()
ؿ ϡ̤λ \fItm\fP Ƥ
\fIformat\fP ǻꤵ줿񼰻ˤäѴ
Ĺ \fImax\fP ʸ \fIs\fP ˽񤭹ࡣ
.PP
ʸ˴ޤޤ̾ʸѴ줺Τޤʸ \fIs\fP
˥ԡ롣Ѵפ '%' ʸǻϤޤꡢ
Ѵʸפǽü롣
ʲΤ褦Ѵ \fIs\fP ˳Ǽ:
.TP
.B %a
ߤΥˤξά̾
.TP
.B %A
ߤΥˤδ̾
.TP
.B %b
ߤΥˤξά̾
.TP
.B %B
ߤΥˤδ̾
.TP
.B %c
ߤΥˤưŪաɽ
.TP
.B %C
 (ǯξ 2 ) (SU)
.TP
.B %d
̻ (10 ʿɽ) (01-31)
.TP
.B %D
.B %m/%d/%y
(áꥫѤꥫʳιǤ
.B %d/%m/%y
Ūʶ路ΤǡѤ٤ǤϤʤ) (SU)
.TP
.B %e
.B %d
Ʊͤ˷̻ 10 ʿɽ뤬
1 ξ 10 ΰ̤˥֤ڡ֤(SU)
.TP
.B %E
̷Ѥݤνҡȡ (SU)
.TP
.B %F
.B %Y-%m-%d
 (ISO 8601 եեޥå) (C99)
.TP
.B %G
ISO 8601 ǯ ( 10 ʿɽ)
ISO 
.RB ( %V
򻲾) б 4 ǯ
ϴŪˤ
.B %y
ƱISO ǯǯˤʤ
ˤϤǯѤ롣(TZ)
.TP
.B %g
.B %G
Ʊ͡âޤޤ 2 Τߤɽ (00-99) (TZ)
.TP
.B %h
.B %b
 (SU)
.TP
.B %H
24 ɽǤλ (hour) (00-23)
.TP
.B %I
12 ɽǤλ (hour) (01-12)
.TP
.B %j
ǯνᤫ̻ (001-366)
.TP
.B %k
24 ɽǤλ (0-23)
1 ξˤ˥Ǥʤڡ֤롣
.RB ( %H
⻲) (TZ)
.TP
.B %l
12 ɽǤλ (0-12)
1 ξˤ˥Ǥʤڡ֤롣
.RB ( %I
⻲) (TZ)
.TP
.B %m
 (10 ʿɽ) (01-12)
.TP
.B %M
ʬ (10 ʿɽ) (00-59)
.TP
.B %n
ԡ (SU)
.TP
.B %O
̷Ѥݤνҡʲ򻲾ȡ(SU)
.TP
.B %p
ߤΥˤָסָפʸ
Ѹξˤ 'AM' ޤ 'PM' Ȥʤ롣
ϸ塢ϸȤư롣
.TP
.B %P
.B %p
ƱͤǤ뤬ʸѤ롣
Ѹξˤ 'am'  'pm' Ȥʤ롣(GNU)
.TP
.B %r
Ǥλ
POSIX Ǥ
.B "%I:%M:%S %p"
Ǥ롣(SU)
.TP
.B %R
24 ɽǤλäɽʤ
.RB ( %H:%M )
äޤΤϰʲ
.B %T
򻲾Ȥ뤳ȡ(SU)
.TP
.B %s
 (1970ǯ 1  1  00:00:00 UTC) ÿ (TZ)
.TP
.B %S
 (10 ʿɽ) (00-60)
(뱼äб뤿ᡢͤϰϤ 60 ޤǤȤʤäƤ)
.TP
.B %t
ʸ (SU)
.TP
.B %T
24 ɽλ (\fB%H:%M:%S\fP) (SU)
.TP
.B %u
βܤ (10 ʿɽ)  1 Ȥ (1-7)
.B %w
⻲ȡ(SU)
.TP
.B %U
ǯνᤫ̻ν (10 ʿɽ) (00-53)
ǯκǽ 1 λϤޤȤƷ׻롣
.B %V

.B %W
⻲Ȥ뤳ȡ
.TP
.B %V
ISO 8601:1988 ǤǯλϤᤫν (10 ʿɽ) (00-53)
ǯ˾ʤȤ 4 ʾޤޤǽν 1 ȤƷ׻롣
λϤޤϷȤ롣
.B %U

.B %W
⻲Ȥ뤳ȡ
.TP
.B %w
βܤ (10 ʿɽ)  0 Ȥ롣(0-6)
.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˳Ǽ줿ʸ֤
ʸ˽ü NULL ХȤϴޤޤʤ
ü NULL ХȤǼǤ礭äʸϤȡ
ʳξ 0 ֤ʸƤϽʤ
(libc 4.4.4 ʹߤǤεưŬѤƤ롣
libc 4.4.1 ʤɤ˸ŤС libc Ǥ
ʸû᤮ˤ \fImax\fP ֤롣)
.LP
֤ 0 ɬ⥨顼̣ƤǤϤʤΤդ뤳ȡ
㤨С¿ΥǤ
.B %p
϶ʸ֤
.SH Ķѿ
Ķѿ
.B TZ

.B LC_TIME
Ѥ롣
(:
.B LC_ALL
ꤵƤˤ
.B LC_TIME
⤽餬ͥ褵롣
.B LC_TIME

.B LC_ALL
ꤵƤʤˤ
.B LANG
Ѥ롣)
.SH 
SVr4, C89, C99.
ġѴ̩ˤɤεʤ˴ޤޤ뤫ϡ
ANSI C (ʤ) UNIX  (SU)Olson  timezone ѥå (TZ)
glibc ȼ (GNU) ǼƤ롣glibc2 Ǥ
.B %+
ϥݡȤƤʤ
ĤγĥԤƤ롣POSIX.1 Ǥ ANSI C Τߤ򻲾ȤƤ롣
POSIX.2 
.BR date (1)
ΤȤ˵ҤƤĤγĥ
.BR strftime ()
ˤŬѤǤ
.B %F
Ѵ C99  POSIX.1-2001 ˤ롣

SUSv2 Ǥϡ
.B %S
 00  61 ϰϤȤȵꤵƤ롣
ϡ1ʬ֤Τä 2ǽŪˤϤ뤳Ȥ
θƤΤΤǤ (ºݤˤϡΤ褦ʾϤޤǰ٤
äƤʤ)
.SH 
.SS glibc Ǥ
glibc ǤѴˤĤĥԤäƤ
(γĥ POSIX.1-2001 ˤϵꤵƤʤ
¾ΤĤΥƥƱͤεǽ󶡤Ƥ)
.\" HP-UX  Tru64 ˤƱͤεǽ롣
\&'%' ʸѴʸδ֤ˡץȤ
.I flag
ȥեɤ
.I 
Ǥ (ꤹˤ
.B E

.B O
Ҥ֤)

ʲΥե饰ʸѤǤ:
.TP
.B _
()
ͤηʸΥѥǥ () 򥹥ڡ (ʸ) ǹԤ
.TP
.B \-
(å)
ͤηʸФѥǥ󥰤Ԥʤ
.TP
.B 0
ѴʸǥեȤǤϥڡǥѥǥ󥰤ԤǤ⡢
ͤηʸؤΥѥǥ󥰤 0 ǹԤ
.TP
.B ^
ʸΥե٥åʸʸѴ롣
.TP
.B #
ʸʸʸؤ
(Υե饰ѴʸǤǽʤǤ
ͭѤʤΤ
.B %Z
ξǤ)
.PP
ץ10ʿҤϥե饰θ֤ȤǤ
(ե饰ϤʤƤ褤)եɤ礭ꤵ줿
硢ʸκ¦ϻꤵ줿ޤǥѥǥ󥰤롣
.SH Х
.BR gcc (1)
ΤĤΥСˤϤʤȤꡢ
.B %c
λˡˤĤưʲΤ褦ʷٹФ:
.I "warning: `%c' yields only last 2 digits of year in some locales"
.RI ( ٹ: ĤΥǤ `%c' ǯβ2夷Ϥʤ )
ץޤ
.B %c
ȤΤϤǤ뤳ȤǤ롣
.B %c
ȤŬڤդȻɽ뤳ȤǤ뤫Ǥ롣
.BR gcc (1)
Τ򤷤褦Ȥȡäꤷʤʬˤʤ
Ū줤ʲˡϰʲΤ褦ִؿɲä뤳ȤǤ롣
.in +4n
.nf

size_t
my_strftime(char *s, size_t max, const char *fmt,
            const struct tm *tm)
{
    return strftime(s, max, fmt, tm);
}
.fi
.in
.RE

ߤǤϡ
.BR gcc (1)
Ϥηٹޤ뤿 \fI\-Wno\-format\-y2k\fP ץ
󶡤Ƥꡢ嵭βϤϤɬפʤ
.SH 
ʲΥץȤ
.BR strftime ()
μ¸Ǥ롣
.nf

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
    char outstr[200];
    time_t t;
    struct tm *tmp;

    t = time(NULL);
    tmp = localtime(&t);
    if (tmp == NULL) {
        perror("localtime");
        exit(EXIT_FAILURE);
    }

    if (strftime(outstr, sizeof(outstr), argv[1], tmp) == 0) {
        fprintf(stderr, "strftime returned 0");
        exit(EXIT_FAILURE);
    }

    printf("Result string is \\"%s\\"\\n", outstr);
    exit(EXIT_SUCCESS);
} /* main */
.fi
.PP
ʲˡ
.BR strftime ()
 glibc ̤򤤤Ĥ:
.nf

$ ./a.out "%m"
Result string is "11"
$ ./a.out "%5m"
Result string is "00011"
$ ./a.out "%_5m"
Result string is "   11"
.fi
.SH Ϣ
.BR date (1),
.BR time (2),
.BR ctime (3),
.BR setlocale (3),
.BR sprintf (3),
.BR strptime (3)