File: getdate.3

package info (click to toggle)
manpages-ja 0.5.0.0.20100315-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 21,156 kB
  • ctags: 1
  • sloc: sh: 13,935; perl: 157; makefile: 114
file content (295 lines) | stat: -rw-r--r-- 7,589 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
.\" Copyright 2001 walter harms (walter.harms@informatik.uni-oldenburg.de)
.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
.\"     <mtk.manpages@gmail.com>
.\"
.\" 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.
.\"
.\" Modified, 2001-12-26, aeb
.\" 2008-09-07, mtk, Various rewrites; added an example program.
.\"
.\" Japanese Version Copyright (c) 2002 NAKANO Takeo
.\" and Copyright (c) 2008, Akihiro MOTOKI all rights reserved.
.\"
.\" Translated 2002-01-12, NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\" Updated 2008-09-20, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.09
.\"
.\"WORD:	broken-down time	̤λ
.\"
.TH GETDATE 3 2008-09-07 "" "Linux Programmer's Manual"
.SH ̾
getdate, getdate_r \- դȻʸ̤λѴ
.SH 
.B "#define _XOPEN_SOURCE 500"
.br
.B "#include <time.h>"
.sp
.BI "struct tm *getdate(const char *" string );
.sp
.B "extern int getdate_err;"
.sp
.B "#define _GNU_SOURCE"
.br
.B "#include <time.h>"
.sp
.BI "int getdate_r(const char *" string ", struct tm *" res );
.SH 
.BR getdate ()
ؿϡ
.I string
ؤХåե˳Ǽ줿ʸɽդȻ
̤λ (broken-down time) Ѵ롣
̤λ
.I tm
¤Τ˳Ǽ졢ι¤ΤؤΥݥ󥿤ؿη̤Ȥ֤롣

.I tm
¤ΤŪʥΰˤꡢ
.BR getdate ()
ΤʹߤθƤӽФǾ񤭤뤫⤵ʤ
.PP
.RI ( format
ǥեޥåȤꤹ)
.BR strptime (3)
Ȥϰ㤤
.BR getdate ()
ϴĶѿ
.B DATEMSK
ǻꤵ줿եѥ̾Υե˽񤤤ƤեޥåȤѤ롣
.PP
ޥåκݤˤʸʸ̤ʤ
ѥǤѴʸǤ⡢;ʬʶʸ̵뤵롣
.PP
ѥ˻ǤѴϡ
.BR strptime (3)
ΤΤƱǤ롣
POSIX.1-2001 ǤϰĤѴ꤬ɲäǵꤵƤ롣
.TP
.B %Z
ॾ̾
glibc ǤϼƤʤ
.LP
.B %Z
ꤵ줿硢̤λǼ빽¤Τϡ
ꤵ줿ॾˤ븽߻бͤǽ롣
ꤵƤʤ硢ι¤ΤϸߤΥ륿б
̤λǽ
.RB ( localtime (3)
ƤӽФƱ)
.LP
ꤵ줿硢
ޤϺʹߤǡ
˹פǽѤ롣
.LP
(ǯʤ) ꤵ줿硢
ޤϺʹߤǡ
η˹פǽηѤ롣
.LP
ʬäꤵʤä硢
ߤλʬäѤ롣
.LP
դλ꤬ʤä (hour) ꤵ줿ϡ
ߤλ֤ޤϤʹߤǡλ˹פǽλ֤Ѥ롣

.BR getdate_r ()
 GNU ĥ
.BR getdate ()
ΥꥨȥǤ󶡤Ƥ롣
.BR getdate_r ()
Ǥϡ顼𤹤Τ˥ХѿѤꡢ
̤λ֤ΤŪʥХåեѤꤻ
顼ؿ֤ͷͳ𤷡̤λ

.I res
ؤƤӽФ¦dzƤХåե˳Ǽ֤
.SH ֤
ȡ
.BR getdate ()

.I struct tm
ؤΥݥ󥿤֤
Ԥ NULL ֤Хѿ
.I getdate_err
˰ʲ˼顼ֹΤ줫Ĥꤹ롣
.I errno
ѹˤĤƤϵꤵƤʤ

ȡ
.BR getdate_r ()
 0 ֤
Ԥȡʲ˼顼ֹΤ줫Ĥ֤
.SH 顼
ʲΥ顼
.RB ( getdate ()
Ǥ)
.I getdate_err
ͳ֤졢
.RB ( getdate_r ()
Ǥ) ؿ֤ͤȤ֤롣
.TP 4n
.B 1
Ķѿ
.B DATEMASK
̤ޤϤͤʸǤ롣
.TP
.B 2
.B DATEMSK
ǻꤵ줿ƥץ졼ȥեɤ߹Ѥ˥ץǤʤ
.TP
.B 3
եΥơ󤬼Ǥʤ
.\" stat()
.TP
.B 4
ƥץ졼ȥե뤬̾ΥեǤʤ
.TP
.B 5
ƥץ졼ȥեɤ߹˥顼ä
.TP
.B 6
γƤ˼Ԥ (꤬­ʤ)
.\" 顼 6  glibc Ǥȯʤ褦˸롣
.TP
.B 7
Ϥ˥ޥåեˡԤޤޤƤʤ
.TP
.B 8
ϻ꤬ʤ
.SH Ķѿ
.TP
.B DATEMSK
񼰥ѥޤե롣
.TP
.BR TZ ", " LC_TIME
.BR strptime (3)
Ѥѿ
.SH 
POSIX.1-2001.
.SH 
POSIX.1-2001 ͤǤϡ
.BR strptime (3)
ˤĤƤ
.B %E

.B %O
ȤäҤѤѴꤷƤ뤬
.BR getdate ()
ˤĤƤϤΤ褦ʽҤεϤʤ
glibc Ǥϡ
.BR getdate ()

.BR strptime (3)
ѤƼƤꡢ
ξԤǤƱѴξԤǥݡȤƤ롣
.SH 
ʲΥץϡޥɥ饤Τ줾ˤĤ
.BR getdate ()
ƤӽФ줾ˤĤ֤줿
.I tm
¤ΤΥեͤɽ롣
Υ롦åϡץưǤ롣

.in +4n
.nf
.RB "$" " TFILE=$PWD/tfile"
.RB "$" " echo \(aq%A\(aq > $TFILE " "      # Full weekday name"
.RB "$" " echo \(aq%T\(aq >> $TFILE" "      # ISO date (YYYY-MM-DD)"
.RB "$" " echo \(aq%F\(aq >> $TFILE" "      # Time (HH:MM:SS)"
.RB "$" " date"
.RB "$" " export DATEMSK=$TFILE"
.RB "$" " ./a.out Tuesday \(aq2009-12-28\(aq \(aq12:22:33\(aq"
Sun Sep  7 06:03:36 CEST 2008
Call 1 ("Tuesday") succeeded:
    tm_sec   = 36
    tm_min   = 3
    tm_hour  = 6
    tm_mday  = 9
    tm_mon   = 8
    tm_year  = 108
    tm_wday  = 2
    tm_yday  = 252
    tm_isdst = 1
Call 2 ("2009-12-28") succeeded:
    tm_sec   = 36
    tm_min   = 3
    tm_hour  = 6
    tm_mday  = 28
    tm_mon   = 11
    tm_year  = 109
    tm_wday  = 1
    tm_yday  = 361
    tm_isdst = 0
Call 3 ("12:22:33") succeeded:
    tm_sec   = 33
    tm_min   = 22
    tm_hour  = 12
    tm_mday  = 7
    tm_mon   = 8
    tm_year  = 108
    tm_wday  = 0
    tm_yday  = 250
    tm_isdst = 1
.fi
.in
.SS ץΥ
\&
.nf
#define _GNU_SOURCE 500
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
    struct tm *tmp;
    int j;

    for (j = 1; j < argc; j++) {
        tmp = getdate(argv[j]);

        if (tmp == NULL) {
            printf("Call %d failed; getdate_err = %d\\n",
                   j, getdate_err);
            continue;
        }

        printf("Call %d (\\"%s\\") succeeded:\\n", j, argv[j]);
        printf("    tm_sec   = %d\\n", tmp\->tm_sec);
        printf("    tm_min   = %d\\n", tmp\->tm_min);
        printf("    tm_hour  = %d\\n", tmp\->tm_hour);
        printf("    tm_mday  = %d\\n", tmp\->tm_mday);
        printf("    tm_mon   = %d\\n", tmp\->tm_mon);
        printf("    tm_year  = %d\\n", tmp\->tm_year);
        printf("    tm_wday  = %d\\n", tmp\->tm_wday);
        printf("    tm_yday  = %d\\n", tmp\->tm_yday);
        printf("    tm_isdst = %d\\n", tmp\->tm_isdst);
    }

    exit(EXIT_SUCCESS);
}
.fi
.SH Ϣ
.BR time (2),
.BR localtime (3),
.BR setlocale (3),
.BR strftime (3),
.BR strptime (3),
.BR feature_test_macros (7)