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
|
.\" 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
.\" Modified Sat Jul 24 19:49:27 1993 by Rik Faith (faith@cs.unc.edu)
.\" Modified Fri Apr 26 12:38:55 MET DST 1996 by Martin Schulze (joey@linux.de)
.\" Modified 2001-11-13, aeb
.\" Modified 2004-11-16, mtk
.\"
.\" Japanese Version Copyright (c) 1997 Hiroaki Nagoya
.\" all rights reserved.
.\" Translated 1997-02-10, Hiroaki Nagoya <nagoya@is.titech.ac.jp>
.\" Updated 1999-09-01, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2001-10-15, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2001-12-13, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2002-01-03, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2008-04-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.79
.\" Updated 2008-08-08, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
.\" Updated 2008-11-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
.\"
.\"WORD: Coordinated Univarsal Time
.\"WORD: broken-down time ̤λ
.\"
.TH CTIME 3 2009-03-15 "" "Linux Programmer's Manual"
.SH ̾
asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r,
localtime_r \- դȻ̤λ ASCII Ѵ
.SH
.nf
.B #include <time.h>
.sp
.BI "char *asctime(const struct tm *" tm );
.br
.BI "char *asctime_r(const struct tm *" tm ", char *" buf );
.sp
.BI "char *ctime(const time_t *" timep );
.br
.BI "char *ctime_r(const time_t *" timep ", char *" buf );
.sp
.BI "struct tm *gmtime(const time_t *" timep );
.br
.BI "struct tm *gmtime_r(const time_t *" timep ", struct tm *" result );
.sp
.BI "struct tm *localtime(const time_t *" timep );
.br
.BI "struct tm *localtime_r(const time_t *" timep ", struct tm *" result );
.sp
.BI "time_t mktime(struct tm *" tm );
.fi
.sp
.in -4n
glibc εǽޥ
.RB ( feature_test_macros (7)
):
.in
.sp
.BR asctime_r (),
.BR ctime_r (),
.BR gmtime_r (),
.BR localtime_r ():
.br
_POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
_SVID_SOURCE || _POSIX_SOURCE
.SH
ؿ
.BR ctime (),
.BR gmtime (),
.BR localtime ()
\fItime_t\fP ΥˤȤ롣
ϡ (UTC) 1970 ǯ 1 1 00:00:00
ηвÿȲᤵ롣
.PP
ؿ
.BR asctime ()
.BR mktime ()
ǯʤɤʬΥ줿̤λȤ롣
.PP
̤λ \fI<time.h>\fP ǰʲΤ褦Ƥ
\fItm\fP ¤Τݻ롣
.sp
.in +4n
.nf
struct tm {
int tm_sec; /* */
int tm_min; /* ʬ */
int tm_hour; /* */
int tm_mday; /* */
int tm_mon; /* */
int tm_year; /* ǯ */
int tm_wday; /* */
int tm_yday; /* ǯ̻ */
int tm_isdst; /* ƻ */
};
.fi
.in
.PP
\fItm\fP ¤ΤΥСϰʲ̤:
.TP 10
.I tm_sec
ÿդĤ 0 59 ޤǤ͡
äΤ 60 ޤǤͤϵ롣
.TP
.I tm_min
ʬ0 59 ޤǤ͡
.TP
.I tm_hour
椫̻֡0 23 ޤǤ͡
.TP
.I tm_mday
Ϥᤫ1 31 ޤǤ͡
.TP
.I tm_mon
1̻0 11 ޤǤ͡
.TP
.I tm_year
1900 ǯ̻ǯ
.TP
.I tm_wday
̻()0 6 ޤǤ͡
.TP
.I tm_yday
1 1 ̻0 365 ޤǤ͡
.TP
.I tm_isdst
ƻ֤ͭɤΥե饰
ͤʤвƻ֤ͭˤʤꡢ0 ʤ̵ͤʤФξˤ
̣ʤ
.PP
.BI ctime( t )
ؿϡ
.BI asctime(localtime( t ))
Ǥ롣
\fIt\fP
.sp
.RS
"Wed Jun 30 21:49:08 1993\\n"
.RE
.sp
Ȥ NULL ü줿ʸѴ롣
άΤ
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" Ǥ롣
άΤ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec" Ǥ롣
֤ͤϡŪ (static) ˳Ƥ줿ʸؤΥݥǤ롣
ʸϡաؿΤ줫ƤӽФȾ뤳Ȥ롣
ޤδؿѿ \fItzname\fP, \fItimezone\fP, \fIdaylight\fP
˸ߤΥॾξꤹ
.RB ( tzset (3)
)
ꥨȥǤǤ
.BR ctime_r ()
Ʊͤ
ʸϥ桼ѰդХåե˳Ǽ롣ХåեΥ
ʤȤ 26 ХȰʾǤʤФʤʤ
δؿ \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP
ꤹɬפϤʤ
.PP
ؿ
.BR gmtime ()
ϡ \fItimep\fP
(UTC) Ǥ̤λѴ롣
ǯ˼ޤʤ硢NULL ֤
֤ͤŪ˳ݤ줿¤ΤؤƤꡢθ
դ˴ؤؿΤ줫ƤӽФ
ǽ롣
.BR gmtime_r ()
Ʊͤ
ǡϥ桼Ѱդ¤Τ˳Ǽ롣
.PP
ؿ
.BR localtime ()
ϡ桼ꤷॾǤλǤѴ롣
δؿ
.BR tzset (3)
ƤӽФΤ褦˿
ѿ \fItzname\fP ˸ߤΥॾξꤹ롣
ޤ\fItimezone\fP ˶ (UTC) ȥɸȤ
ÿꤷ
ǯΰDzƻ֤ŬѤ \fIdaylight\fP 0 ꤵ롣
֤ͤŪ˳ݤ줿¤ΤؤƤꡢθ
դ˴ؤؿΤ줫ƤӽФ
ǽ롣
.BR localtime_r ()
Ʊͤ
ǡϥ桼Ѱդ¤Τ˳Ǽ롣
δؿ \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP
ꤹɬפϤʤ
.PP
ؿ
.BR asctime ()
ϡ̤λ \fItm\fP
.BR ctime ()
Ʊ NULL ü줿ʸѴ롣
֤ͤŪ˳Ƥ줿ʸؤΥݥǤ롣ʸϡ
աؿΤ줫ƤӽФȾ뤳Ȥ롣
ꥨȥǤǤ
.BR asctime_r ()
Ʊͤ
ʸϥ桼ѰդХåե˳Ǽ롣ХåեΥ
ʤȤ 26 ХȰʾǤʤФʤʤ
.PP
ؿ
.BR mktime ()
ϡ(륿ǵҤƤ) ̤λ
Ѵ롣κݡƤӽФե
.I tm_wday
.I tm_yday
ǻꤷ̵ͤ뤵롣
.BR mktime ()
ϡե
.I tm_isdst
ǻꤵ줿ͤˤꡢ
.I tm
¤ΤϤ줿Dzƻ (daylight saving time; DST) ͭˤʤä
뤫Τ롣
ͤϲƻ֤ͭǤ뤳Ȥ̣롣
ͤǤС
.BR mktime ()
(ॾȥƥΥǡ١Ȥä)
ꤵ줿Dzƻ֤ͭɤȽǤɬפ뤳Ȥ̣롣
.BR mktime ()
.I tm
¤ΤγƥեɤʲΤ褦˽롣
.I tm_wday
.I tm_yday
ˤ¾ΥեɤƤͤꤹ롣
¤ΤǤͭϰϤˤʤ硢
(㤨С10 40 11 9 ѹ)
.I tm_isdst
ˤ (ǽͤˤ餺) ͤ 0 ꤵ롣
ͤϻꤵ줿֤Dzƻ֤ͭǤ뤳Ȥ
0 ̵Ǥ뤳Ȥ
ؿ
.BR mktime ()
ƤӽФȡ
ѿ \fItzname\fP ߤΥॾꤵ롣
̤λ ( (Epoch) ÿ) ɽǤʤ硢
.BR mktime ()
.I (time_t)\ (-1)
֤̤λι¤ΥСѹʤ
.SH ֤
ƴؿϤ줾Ҥ֤ͤ顼ξ NULL
.RB ( mktime ()
Ǥ \-1) ֤
.SH
POSIX.1-2001.
C89 C99 Ǥ
.BR asctime (),
.BR ctime (),
.BR gmtime (),
.BR localtime (),
.BR mktime ()
ꤵƤ롣
POSIX.1-2008 ϡ
.BR asctime (),
.BR asctime_r (),
.BR ctime (),
.BR ctime_r ()
ѻͽȤƤ롣
ˡ
.BR strftime (3)
λѤ侩Ƥ롣
.SH
.BR asctime (),
.BR ctime (),
.BR gmtime (),
.BR localtime ()
4 ĤδؿŪǡؤΥݥ֤ΤǡåɥդǤϤʤ
δؿΥåɥǤǤ
.BR asctime_r (),
.BR ctime_r (),
.BR gmtime_r (),
.BR localtime_r ()
SUSv2 ǵꤵƤꡢ
libc 5.2.5 ʹߤѤǤ롣
POSIX.1-2001 Ǥϡִؿ
.BR asctime (),
.BR ctime (),
.BR gmtime (),
.BR localtime ()
ϡ̤λι¤Τ
.I char
Τɤ餫Ū֥Ȥ֤ΤȤ롣
δؿΤ줫¹Ԥȡ¾δؿΤɤ줫
Ū֥ȤΤɤ餫˳Ǽ֤뤫
ʤפȤʤäƤ롣
ΤȤ glibc μǵꤦ롣
.LP
glibc ޤ¿μǤϡ
.I tm_mday
0 ꤹκǽ̣ƤȲᤵ롣
.LP
glibc Ǥϡ
.I <time.h>
롼ɤ
.B _BSD_SOURCE
ȡ
\fIstruct tm\fP ˰ʲΥեɤɲä롣
.sp
.RS
.nf
long tm_gmtoff; /* Seconds east of UTC */
const char *tm_zone; /* Timezone abbreviation */
.fi
.RE
.sp
BSD ĥǤꡢ4.3BSD-Reno 鸽줿
POSIX.1-2004 ˤȡ
.BR localtime ()
Ϥ
.BR tzset ()
ƤФ줿Τ褦˿ȤᤵƤ뤬
.BR localtime_r ()
ˤϤϤʤ
.\" http://thread.gmane.org/gmane.comp.time.tz/2034/ ȡ
ܿɬפʥɤǤϡ
.BR localtime_r ()
.BR tzset ()
ƤӽФƤ٤Ǥ롣
.SH Ϣ
.BR date (1),
.BR gettimeofday (2),
.BR time (2),
.BR utime (2),
.BR clock (3),
.BR difftime (3),
.BR strftime (3),
.BR strptime (3),
.BR timegm (3),
.BR tzset (3),
.BR time (7)
|